I have variable DomainSuffix which is defined differently for each environment. The same variable happens to be set by channels too. So what is going to happen when Environment scope dictates one value and Channel scope dictates another? For my particular purpose I need Channel scoped value to override Environment scoped value. How do I make sure it is the case?
Thanks for getting in touch.
By default, channels have a lower precedence than environments (see the ‘Scope specificity’ section of the Scoping Variables documentation.
In your case, where you need the channel-scoped value to override the environment-scope value, you could setup your DomainSuffix variable like so:
[variable] | [scope]
DomainSuffix | MyEnvironment
DomainSuffix | MyEnvironment, MyChannel (note this is scoped to BOTH environment and channel)
This would then add the environment rank + the channel rank and would ensure your environment+channel scoped variable has precedence.
Hope this helps.
I don’t understand that notation: [variable] | [scope] DomainSuffix | MyEnvironment
But hopefully I understand the general idea to make channel scoped version more specialized that environment one by specifying both Environment AND Channel for it. Right?
Yes sorry, the formatting got messed up in my reply. I was just trying to indicate that you can define both an environment and a channel for your variable and it will take precedence over the variable that is scoped only to an environment.