Determine Tenant Environment During Script Execution

Determine Tenant Environment During Script Execution

Anonymous
Not applicable
554 Views
1 Reply
Message 1 of 2

Determine Tenant Environment During Script Execution

Anonymous
Not applicable

I would like to know if my script is executing in the preview tenant or the production tenant at run-time.  This will allow me to ensure that preview tenant scripts only interact with development/test/sandbox external APIs and production tenant scripts only interact with external production APIs  Is it possible to determine the environment at run-time within a script?

0 Likes
555 Views
1 Reply
Reply (1)
Message 2 of 2

fred_smith
Autodesk
Autodesk

I assume you are asking about in-application scripting (i.e., Administration -> System Configuration -> Scripting).

 

The good news... all scripting access is constrained to the current container/tenant. So, you don't have to worry about corrupting any data outside the tenant where a script is running.

 

The bad news... the short answer to your question is "NO". Because of the cloud infrastructure involved, it is not possible to determine the tenant environment (i.e., fully qualified machine name) from within your tenant. If you really do need the tenant FQMN (e.g., to create links to your tenant in custom e-mails), then best practice is to write a simple one-line library convenience function - say getTenantName() - in a library that returns a constant string. This way, only one line of script must change if you copy scripts from sandbox tenant to production tenant.



Fred Smith

Sr. Solution Architect
0 Likes