Skip to main content
francoh7128
Participating Frequently
Nov 19, 2024 5:20 PM UTC
Question

Obtain App Name/Environment Metadata or URL?

My project exists as three environments hosted on three separate URLs with three separate app names (dev, test and production respectively).  I want to make changes to my interfaces that only render in certain environments (mainly dev) so that they don't interfere with the client's UI experience.  I was wondering if there was some sort of metadata or variable that I could use to identify them for conditional logic.  I know pp! variables do something similar for processes.  Also, using string fragments from the unique parts of the URLs might work too, but I wasn't sure what methods are the current gold standard.

4 replies

davidj137213
Brainy
Nov 19, 2024 5:38 PM UTC

Create a constant, the same in all environments... and check the value inside your interfaces in order to control the behavior...

francoh7128
Participating Frequently
Nov 19, 2024 6:51 PM UTC

Ok, so the constant's handle stays the same, it's merely the value that I set within the interface that changes from environment to environment/app to app?  I had assumed that a constant had to be set and available globally, but I might be confusing that with something else.

davidj137213
Brainy
Nov 19, 2024 7:56 PM UTC

That's it... 

mathieud0001
Genius
Nov 20, 2024 12:16 PM UTC

You can use an expression to extract the hostname from the URL and then devise a rule to determine which environment you're in.