Discussions
Join the NetSuite community to innovate, connect, and discover what’s next.
SuiteWorld brings thousands of innovators, builders, and leaders together to learn, connect, and shape what’s next. This October, explore how to build a stronger foundation for growth through inspiring keynotes, major product reveals, hands-on sessions, and unforgettable moments—all in one place for our biggest event of the year. Register now
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}