Hey Everyone,
I know this has been covered a number of times on this forum, but none of the answers seem to correct my issue.
Everytime I try to run basic code to transform a sales order to a cash sale after submit, I get the following err:
INVALID_INITIALIZE_REF Details: You have an invalid sales order 9166560 or the order is already closed
The status of the SO is always pending approval when I inspect it via the debugger. I already have ‘Advanced Shipping’ enabled as someone suggested before. I have also tried enabling “Invoice in Advance of Fulfillment”. No matter what I get the above error. The code is pretty barebones, and I feel like it should work, though it does not. Any help would be appreciated.
Code:
var salesOrderId = nlapiGetRecordId();
var salesOrderRecord = nlapiLoadRecord(‘salesorder’, salesOrderId);
var recordStatus = salesOrderRecord.getFieldValue(‘status’);
try {
var cashSale = nlapiTransformRecord(‘salesorder’, salesOrderId, ‘cashsale’);
cashSale.setFieldValue(‘trandate’, salesOrderRecord.getFieldValue(‘trandate’));
cashSale.setFieldValue(‘chargeit’, ‘T’);
nlapiSubmitRecord(cashSale);
} catch (err) {
nlapiLogExecution(‘ERROR’, err);
}
This is a cached copy. Click here to see the original post.