Getting Current Environment Context


Badge +1

Is there a way from inside a server event to get the current environment (whether it is Development or Production)?  There seem to be any number of ways to get the value of the environment variables within that environment, but there doesn't look to be an easy way to get which environment the process is running within.  I could parse the Workflow Server environment field, but I don't want my process to be dependent on the name of the K2 server. 


Is there a way to do this?


6 replies

Badge +10

I'm not aware of a out of the box configured way of doing this. 


However, what if you just create a new Environment variable called somethink like "K2 Environment".  And then simply set the value as "Development" in Development, and "Production" in production.  That should be a one time quick configuration.


Then in your workflow you could evaluate that enviornment variable which at runtime would retrieve the string table entry for whatever enviornment its running in.


Regards,


Tim

Badge +1

That's actually a really good idea.  However, I've added the variable to the environment, and it's not available in the K2.StringTable.  Is there something that I need to do to refresh the StringTable to include the new variable?

Badge +6

you will see the new entries in the string table only after deploying the version.

Badge +1

I deployed the new version of the process, and I'm still getting an error when I run the process that says that the variable doesn't exist.  Are you talking about deploying the version of something else?

Badge +10

Sujeeth was correct that for the environment variable to show up in the string table a process needed to be deployed into each environment (maybe that was the step that was missed).  Then look in the k2 workspace in your development environment and ensure that the string table entry has the correct value.  If not then edit the entry.


After you've done that for development go to the Production workspace and also check the string table entry in production.


Regards,


Tim

Badge +6

I am referring to the workflow itself. So after deploying, can you see the variables in database...[_StringTable]

Reply