How is your experience with the OutSystems Community?
318
Views
11
Comments
Solved
Determine environment in a timer
Question

I have a timer set to run on a particular day and time. Since the code and time are published in Dev, Test and Prod, the timer actually runs once in each environment. In order to ensure recipients are not receiving emails generated 3 times, I only want to send if in PROD. 

For my applications, when I need to determine environment, I use GetRequestDomain(). As this is not available when a timer is ran, I tried using GetServerName() but it is empty. 

I also used GetMachineName() but that is the actual server name and I would prefer not to base my logic on a machine name that could change. 

Is there something equivalent to GetRequestDomain() that provides a static domain value? If not, is there some way to have an environment variable (not a site variable in an application as this would not solve the issue due to the same value in all environments after publish/deploy).


Thank you,

David

2021-03-16 13-04-29
Filipe Ramires
Solution

Tivity,

It does work across all environments. The Site Property can be changed per environment in Service Center. See the attached ScreenShot.

To get the Site Property in another eSpace, all that is needed is a function created in the eSpace where the site Property is that returns the value stored (that changes per Environment).

Thanks

teste.png
2021-03-16 13-04-29
Filipe Ramires

Hello @Tivity Health,

A really easy solution is to create a Site Property [Environment] and set the variable in service center to DEV, QAS and PRD (respectively in each service center)

This way, you can easily check the environment the timer is running by checking the Site Property.

Regards,

FRamires

UserImage.jpg
Tivity Health

Thank you for the response Filipe but site property will not work across the environment. A site property is per Espace and I am looking for a way to determine in a timer that is in another espace what the environment currently is. I don't want to have to put this site config in every Espace.


David

2021-03-16 13-04-29
Filipe Ramires
Solution

Tivity,

It does work across all environments. The Site Property can be changed per environment in Service Center. See the attached ScreenShot.

To get the Site Property in another eSpace, all that is needed is a function created in the eSpace where the site Property is that returns the value stored (that changes per Environment).

Thanks

teste.png
UserImage.jpg
Tivity Health

Thank you for the additional information. I see what you were saying and I was wrong in my original assumption. This should solve the issue. 


Thank you!

2021-06-09 13-39-18
Agno Silveira
 
MVP

Hi Tivity Health,

As I understand it you just want to run the timer in production, in this case, have you considered keeping the timer active only in PROD?

You can do in Service Center by Environment:

Regards.

2021-03-08 09-24-09
Rúben Meireles

Hi Tivity,

I believe your problem should be solve at the environment configuration level, recipients should not receive emails from DEV or TEST environments. 

For that you can configure a mailing list in service center:

Regards,

Rúben

UserImage.jpg
Tivity Health

I am using our internal Email service which is access via API and not a configuration in Outsystems, so this would not have any bearing on the issue.

I am trying to determine environment as I will use the solution for other areas where I only want to perform actions in a particular environment, not just sending of emails.

David

UserImage.jpg
Tivity Health

That is interesting and I was not aware of the ability to deactivate, but my intention is keep the timers running in all environments but not send emails in lower environments. This is why I am trying to determine which environment the timer is executing in.


David

2021-03-08 09-24-09
Rúben Meireles

Please see my response above, it should do what you need :) 

2021-06-09 13-39-18
Agno Silveira
 
MVP

Hi Tivity,

See this component.

Hope it's help.

Regards.

2025-09-02 13-37-45
Ricardo Monteiro

Hey folks, I know that this is an old post, but have a look at my forge component Environment Info. It doesn't rely on Site Properties or queries to the system entities of the platform.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.