Modify the document number in sales order for a particular sales order form

try{

            let newRecord = scriptContext.newRecord;

            if (scriptContext.type !== scriptContext.UserEventType.CREATE) {

                return;

            }

   

   

            let targetFormId = [‘197’];

           

       

            let customForm = newRecord.getValue({

                fieldId:“customform”

            });

            log.debug(“customform”,customForm);

   

            if (targetFormId.includes(customForm)) {

                let tranid = newRecord.getValue({fieldId:‘tranid’});

                log.debug(“tranid”,tranid);

                if (tranid) {

                    newRecord.setValue({

                        fieldId: ‘tranid’,

                        value: tranid + ‘EX’

                    });

                }

            }

        } catch (e) {

            log.error(“error@beforeSubmit”, e)

        }

Leave a comment

Your email address will not be published. Required fields are marked *