I have a script (server side) that runs when a specific condition is met (shouldrenew equal to 5) on a custom record...
The script (shown below) creates a simple estimate with one line item. It seems to work very nicely when creating estimates for customers in our US subsidiary, however when attempting to create an estimate for customers in another subsidiary the script will always crash. When I go through the user interface to create these estimates manually, I can do so. However, when selecting a customer from another subsidiary I get a warning:
"The customer you have selected is based in a different nexus, please click okay to change your form to one that works for that nexus"
The only change it makes is that the "gross amount" shows up on the line item level of the form. The form appears to be identical aside from that.
If I am in the customer record (for a foreign subsidiary) and I click create estimate, it goes directly to a version of my form that includes "gross amount" on the line item level...
Gold support tells me that they show the crash reason as being "only numerical characters are allowed in this field, but apparently they can't tell which field is the issue. I am blaming this "nexus change" that the form has to undergo. Is there some way to handle this in a script??
Any help is appreciated, thanks in advance...
function createrenewal()
{
var entity=nlapiGetFieldValue('custrecord_parentcustomer');
var supportamount=nlapiGetFieldValue('custrecord_calcamtnextyear');
var shouldrenew=nlapiGetFieldValue('custrecord_renewalstatus');
var memo=nlapiGetFieldValue('custrecord_testfield');
var eligstart=nlapiGetFieldValue('custrecord_nystarttext');
var eligend=nlapiGetFieldValue('custrecord_nyendtext');
var agmtid = nlapiGetRecordId();
if (shouldrenew==5)
{
var newest;
newest = nlapiCreateRecord('estimate');
newest.setFieldValue('customform', 148);
newest.setFieldValue('entity', entity);
newest.setFieldValue('custbody_supportstartext', eligstart);
newest.setFieldValue('custbody_supportendtext', eligend);
newest.setFieldValue('custbody_customerstatus', 2);
newest.setFieldValue('exchangerate', 1);
newest.setFieldValue('class', 11);
newest.setFieldValue('custbody_eventsconfiguration', memo);
newest.setLineItemValue("item", "item", 1, 137);
//newest.setLineItemValue("item", "taxcode", 1, 84);
newest.setLineItemValue("item", "amount", 1, (supportamount*1));
var id = nlapiSubmitRecord(newest, true); //THE SCRIPT WILL CRASH ON THIS LINE!!!
var agmt;
agmt = nlapiLoadRecord('customrecord_suptcon', agmtid);
agmt.setFieldValue('custrecord_renewalstatus', 2);
agmt.setFieldValue('custrecord_nyestimate', id);
worthless = nlapiSubmitRecord(agmt, true);
};
return true;
};