how can a client script determine whether it is be...
# ask-stanley-ai
b
how can a client script determine whether it is being access via the customer portal
c
AI generated answer (using internal Slack threads):
To determine whether a client script is being accessed via the customer portal, you can use the
runtime.executionContext
API in SuiteScript 2.0. This API returns the context in which the script is being executed. Here is a sample code snippet:
Copy code
javascript
var context = runtime.executionContext;
if(context === runtime.ContextType.USER_INTERFACE){
    // The script is being accessed via the UI
} else if(context === runtime.ContextType.CUSTOMER_CENTER){
    // The script is being accessed via the customer portal
}
In this code,
runtime.executionContext
returns the context in which the script is being executed. If the script is being accessed via the customer portal,
runtime.executionContext
will return
runtime.ContextType.CUSTOMER_CENTER
. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816253066
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.811055183
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.806494236
Please provide your feedback on this answer.