Why user event script is working on all sales orders except only one sales order.

I have created user event after submit script to create and set pdf file id on a custom field.  Id is setting on all sales order except 1 sales order. what can be reason? Please help!

 

/**
 *@NApiVersion 2.x
 *@NScriptType UserEventScript
 */
 define([‘N/search’,’N/record’,’N/url’,’N/https’,’N/render’],  function(search,record,url,https,render){
    function afterSubmit(context)
    {
        if(context.type == ‘create’){
        var rec = context.newRecord
        var recId= rec.id;
        log.debug(‘recId’,recId)
        var INVstatus = rec.getValue({fieldId: “status”});
        log.debug(‘INVstatus’,INVstatus)
        var ExportdINV = rec.getValue({fieldId: “custbody_exported_invoice_elogik”});
        var salesorderID = rec.getValue({fieldId: “createdfrom”});
        log.debug(‘salesorderID’,salesorderID)
        //if(INVstatus == “Paid In Full” && ExportdINV == false)
            try {
                    var transactionFile = render.transaction({
                        entityId: parseInt(recId),
                        printMode: render.PrintMode.PDF
                    });
                    transactionFile.folder = 1721;
                    var fileId = transactionFile.save();
                    log.debug(‘Saved PDF to file ‘ + fileId);
                    if(fileId)
                    {
                         record.submitFields({
                        type: record.Type.SALES_ORDER,
                        id: salesorderID,
                        values: {‘custbody_inv_pdf_file_id’: fileId}
                    });
                    }
                }
                catch (error) {
                    log.debug(‘Error File’, error);
                }
    }
    }
return {
       afterSubmit : afterSubmit
  };
});
Beginner Asked on March 16, 2023 in SuiteScript.
Add Comment
1 Answer(s)

Your script is clear, but can you check from custom form / from deployment script that applied at that transaction ? you need check that

Rookie Answered on March 16, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor