Problem: The error "Illegal ID. Please enter a name." is thrown when running the following snippet:
var project = nlapiCopyRecord('job',440);
var projID = nlapiSubmitRecord(project);
When creating a new project record from Lists > Projects > New, users would notice that the Project ID (or the 'entityid' field) is getting copied from 'Project Name' field. However, copying this record would not copy the 'Project ID' field from the existing record as NetSuite makes sure that the 'Project ID' is unique.
Solution 1: Add a setFieldValue() method for setting the 'Project Name' field to be copied to the Project ID. Snippet below:
var project = nlapiCopyRecord('job',440);
project.setFieldValue('companyname','New Project');
var projID = nlapiSubmitRecord(project);
Solution 2: Uncheck 'autoname' field and set the 'entityid' field. Snippet below:
var project = nlapiCopyRecord('job',440);
project.setFieldValue('autoname','F');
project.setFieldValue('entityid','New Project 2');
var projID = nlapiSubmitRecord(project);
Solution 3: Turn on Auto-Generated Number (Only recommended if you'd like NetSuite to auto-generate the 'Project ID' field.) To turn this on, please go to Setup > Company > Auto-Generated Numbers. Click on the checkbox beside 'Project' record and save. The following snippet will now work.
var project = nlapiCopyRecord('job',440);
var projID = nlapiSubmitRecord(project);
No comments:
Post a Comment