Discussions
Join us for complimentary one-day events around the world and step into a future fueled by AI and limitless potential. Explore new breakthroughs, sharpen your skills, and connect with experts who are shaping what’s next. Experience bold keynotes, interactive learning, and connections that span the global NetSuite community. Discover what's next at SuiteConnect Tour 2026.
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}