Generate a suiteSignOn Token Using a User Event Script
The following sample shows how to use generateSuiteSignOnToken(options)
in a user event script.
This script sample uses the define
function, which is required for an entry point script (a script you attach to a script record and deploy). You must use the require
function if you want to copy the script into the SuiteScript Debugger and test it. For more information, see SuiteScript 2.x Global Objects.
The value used in this sample for the suiteSignOnRecordId
field is a placeholder. Before using this sample, replace the suiteSignOnRecordId
field value with a valid value from your NetSuite account. If you run a script with an invalid value, an error may occur. Additionally, the SuiteSignOn record you reference must be associated with a specific script. You make this association in the SuiteSignOn record’s Connection Points sublist. For help with SuiteSignOn records, see Creating SuiteSignOn Records.
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
// This script uses generateSuiteSignOnToken in a user event script.
define(['N/sso'], function(sso) {
function beforeLoad(context) {
var suiteSignOnRecordId = 'customsso_test';
var url = sso.generateSuiteSignOnToken(suiteSignOnRecordId);
}
return {
beforeLoad: beforeLoad
};
});