var rec = nlapiLoadRecord('salesorder', xx); //xx is the internal id of the sales order
var salesrep = rec.getFieldValue('salesrep'); // Will give the internal id of the employee, In order to get the name use getFieldText
// To set the field value
var sales rep = rec.setFieldValue('salesrep',xx); //xx is the internal id of employee
When Team Selling feature is enabled Sales Rep field will disappear on the main body of the transaction and there will be a Sales Team tab created, populate the employee field here in order to set the sales rep. Please refer to the script below :
var rec = nlapiLoadRecord('salesorder', xx); //xx is the internal id of sales order
rec.selectLineItem('salesteam',1);
rec.setLineItemValue('salesteam', 'employee',1, x); //x is the internal id of employee
rec.setLineItemValue('salesteam', 'salesrole',1, x); //x is the internal id of the sales role (Setup > Sales >CRM Lists)
rec.setLineItemValue('salesteam', 'isprimary',1, 'T');
rec.setLineItemValue('salesteam', 'contribution',1, '100');
nlapiCommitLineItem('salesteam');
nlapiSubmitRecord(rec,true);
No comments:
Post a Comment