This topic contains 1 reply, has 0 voices, and was last updated by michoel 7 years, 4 months ago.

  • Author
    Posts
  • #5781 Score: 0

    isJaysen
    • Contributions: 0
    • Level 1

    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.

  • #5782 Score: 0

    michoel
    • Contributions: 0
    • Level 1

    Originally posted by isJaysen

    View Post

    The status of the SO is always pending approval when I inspect it via the debugger

    This is probably your issue. Have you tried approving the Sales Order before transforming it?

You must be logged in to reply to this topic.