Hi,
I am using a script on save event of the estimate form to create a new record in a custom record type.Here is the script:
function onSaveDoc(){
if(nlapiGetFieldText('entityStatus') == 'Closed Won'){
//Generate the records in custom ci table
if(nlapiGetLineItemCount('item') > 0){
for (var i = 1; i <= nlapiGetLineItemCount('item'); i++){
alert('1');
var record = nlapiCreateRecord('customization');
alert('2');
record.setFieldValue('custrecord_cust_id',nlapiGetFieldText('entity'));
record.setFieldValue('name',nlapiGetLineItemValue('item', 'description', i));
record.setFieldValue('custrecordci_name',nlapiGetLineItemValue('item', 'description', i));
record.setFieldValue('custrecord_service_agreement_id',nlapiGetFieldValue('custbodycustbody_said_num'));
var id = nlapiSubmitRecord(record,true);
}
}
}
return true;
}
It gives me the alert1 but doesnot goto the alert2 also if I remove the statement-
var record = nlapiCreateRecord('customization'); (and other statements related to variable record) it allows me to save the estimate record currently when i save the estimate record it gives me alert1 and then an errror 'cannot save record due to an unexpected error'.
So my question is how to create a record for a custom record type using nlapiCreateRecord