Discussions
Read on for the latest updates including:
• Agenda Builder launch
• SuiteWorld On Air registration
• New NetSuite Prompt Studio Contest
• And more!
Check out this thread to learn more!
Using suitescript 2.0 how do I add roles when creating and employee record.
var rec = record.create({
type: record.Type.EMPLOYEE,
isDynamic: true,
defaultValues: Object
})
rec.setValue({ fieldId: 'giveaccess', value: true });
rec.setValue({ fieldId: 'sendemail', value: true });
rec.selectNewLine({ sublistId: 'roles' });
rec.setCurrentSublistValue({
sublistId: 'roles',
fieldId: 'role',
value: rBody.body.role[0] // a role Id 1434
});
rec.commitLine({ sublistId: 'roles' });
var employeeId = rec.save();
I get the error:
{"type":"error.SuiteScriptError","name":"USER_ERROR","message":"Please enter value(s) for: Role","id":"","stack":["Error\n at RecordInvoker.commitLine (suitescript/resources/javascript/record/serverRecordService.js:278:5)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)\n at newEmployee (/SuiteScripts/AllNewEmployee.js:93:26)\n at Object.onRequest (/SuiteScripts/AllNewEmployee.js:34:44)"],"cause":{"type":"internal error","code":"USER_ERROR","details":"Please enter value(s) for: Role","userEvent":null,"stackTrace":["Error\n at RecordInvoker.commitLine (suitescript/resources/javascript/record/serverRecordService.js:278:5)\n at NetSuiteObject.thenableFunction() (suitescript/resources/javascript/record/proxy.js:115:24)\n at newEmployee (/SuiteScripts/AllNewEmployee.js:93:26)\n at Object.onRequest (/SuiteScripts/AllNewEmployee.js:34:44)"],"notifyOff":false},"notifyOff":false,"userFacing":true}