Defining Script Audience
On the Audience subtab on the Script Deployment page, define the audience access for the script. When the script is deployed, it will only run in the roles specified in the Audience subtab.
The Audience subtab is included on the Script Deployment page for these script types: Suitelet, portlet, user event, global client (deployed at the record-level), RESTlet, mass update, and workflow action. You cannot specify an audience for scheduled scripts, map/reduce scripts, or bundle installation scripts.
Mass update script deployments and mass updates can both be assigned an audience. It is the user's responsibility to make sure the two audiences are in sync. For information about working with the mass update script type, see SuiteScript 2.x Mass Update Script Type.

General guidelines for specifying an audience:
-
If you do not specify any values on the Audience subtab, the script will execute only for the script owner even if the script deployment status is set to Released. For information about the differences between the Released and Testing deployment statuses, see Setting Script Deployment Status.
-
If you choose both role and department options on the Audience subtab, a user must belong to one of the selected roles AND one of the selected departments to execute the script. If you choose options for any other combinations of types (groups, employees, and partners), a user need only belong to a selected option of one type OR of another.
-
If you want the script to run only for specific users, select the appropriate roles, departments, groups, employees, or partners. If you want the script to run for all NetSuite users, do the following:
-
Check the Select All box beside the Internal Roles field
-
Select all roles in the External Roles field
Note:When giving access to multiple roles, particularly external roles, ensure that each selected role has a valid need to access the script.
-
Be sure to save the Script Deployment record after all audience members have been defined.
If you are working with Suitelet Script Deployment records, see Errors Related to the Available Without Login URL, which discusses the relevance of the Select All box as it pertains to internally and externally available Suitelets.
Using the Audience Subtab to Test Scripts
If the Status field on the Script Deployment record is set to Testing, you can test scripts assigned to specific audiences if you are a member of that audience type. For information about the Testing deployment status, see Setting Script Deployment Status.
For example, if you have written a script that you want to run for everyone in the Support Management role, you can log into NetSuite and then switch to the Support Management role to test the script. If the deployment status for this script is set to Testing, the script will run for only the script owner. After you have determined that the script runs as expected for the Support Management role, you can change the script's deployment status to Released. After it is set to Released, it will run in the account for all those assigned to the Support Management role.
This is a good approach for script owners to verify that their script will run in the accounts for specified roles, departments, groups, employees, or partners.
Using the Audience Tab in OneWorld Accounts
Script authors/owners who are developing scripts for NetSuite OneWorld accounts can specify a script audience based on subsidiary. In OneWorld accounts, the Audience subtab includes a Subsidiaries multiselect field. After choosing subsidiaries, be sure to click Save on the Script Deployment page.
If the currently logged user is a member of a subsidiary which is selected in the multiselect field on the Script Deployment page, then the script is executed.
Script owners working in a OneWorld account that has multiple subsidiaries can select the subsidiaries they want their script to run in, and then log into an account of one of the specified subsidiaries. When a script's deployment status is set to Testing, the script will execute for the script owner and specified audience. This is a good way for script owners to verify that the script will run in accounts for specified subsidiaries.
