RE: Is there a different way to load ID aftersubmit
Hello NetSuite Professionals – Receiving error “Invalid API usage. You must use getValue to return the value set with setValue”
For UserEvent Script, error recieved when creating a customer, but don’t receive an error when editing an existing customer .. is context.newRecord; correct or is there another way to load the customer ID for a customer just created, to reference?
/**
* @NScriptType UserEventScript
* @NAPIVersion 2.0
*/
define([‘N/record’],
function(record) {
return {
afterSubmit : function(context) {
var customer = context.newRecord;
var subsidiary = customer.getValue(‘subsidiary’);
if(subsidiary == 9){
var newsub = record.create({
type : record.Type.CUSTOMER_SUBSIDIARY_RELATIONSHIP,
isDynamic : true
});
newsub.setValue({
fieldId : ‘entity’,
value : customer.id
});
newsub.setValue({
fieldId : ‘subsidiary’,
value : 5
});
newsub.save();
}
}
}
});
Nvm .. turned out to just be a weird issue with demo account I was using, this works in other production/sandbox accounts.