For one world accounts, it is possible to specify a Script to only execute based on the currently logged in user's subsidiary (Customization > Scripting > Script Deployments > Audience tab). To have a script on a transaction record to execute based on a Transaction Subsidiary, a condition can be added to check if the transaction subsidiary is (suppose) A, then execute the code.
For example, to have a user event script on transaction record to execute only for users of a particular subsidiary and only specific transaction subsidiary, do the following:
1. Navigate to Customization > Scripting > Script Deployment > Edit the script deployment in question > Audience tab > specify the desired subsidiary in the Subsidiaries field> Save
2. In the script code, the following code can be added:
If(subsidiary== 1) // 1 is the internal id of the subsidiary
{
//do this
}
For instance, following is a user event script that sets the field value of Memo field on a Sales Order if the transaction subsidiary is 7 (internal id of the desired subsidiary )
function aftersubmit(type) // after submit function
{
var recordid= nlapiGetRecordId(); // get the current existing record's internal id
var record=nlapiLoadRecord('salesorder',recordid); // load the record
var subsidiary= record.getFieldValue('subsidiary'); // get the transaction subsidiary for the record
if (subsidiary == 7) //check if subsidiary equals the desired subsidiary
{
record.setFieldValue('memo', 'abcd'); //set Memo field = abcd
nlapiSubmitRecord(record); // submit the record
}
}
No comments:
Post a Comment