We are attempting to determine the environment of execution dynamically within the Custom Functions runtime in order to set a group of environment variables. We have multiple environments where our custom functions execute:
- local
- staging
- qa
- production
We would like to avoid generating a separate bundle per environment. Instead we would like to generate a single bundle and determine which environment we are executing in at runtime. This would allow us to determine the appropriate URL for the backend API server that supports our functions for instance.
For our taskpane add-in, we have simply used the value of window.location.hostname to determine the current environment and select the approprate API server URL. This also seems to work as expected while executing in the Custom Functions runtime within Excel on the Mac. Unfortunately, when executing within Excel on Windows, the window object is undefined in the Custom Functions runtime.
- Is it possible to get the hostname that would generally be accessible via window.location.hostname within the Custom Functions runtime?
- If not, we maintain a manifest per environment (e.g. manifest-local.xml, manifest-staging.xml, etc). Is it possible to retrieve values from the application manifest within my custom function logic? For example, if I have the Resources section below in my manifest, could I retrieve the DefaultValue of the Taskpane.Url in my custom function logic?
<Resources>
<bt:Urls>
<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000" />
... ...
</bt:Urls>
</Resources>
- If not, is there another way you would recommend to pass a value that would indicate the current environment to a custom function?
Thanks in advance.