To trigger the script on clicking “Mark Shipped” on Item Fulfilment record

context.UserEventType

  • APPROVE
  • CANCEL
  • CHANGEPASSWORD
  • COPY
  • CREATE
  • DELETE
  • DROPSHIP
  • EDIT
  • EDITFORECAST
  • EMAIL
  • MARKCOMPLETE
  • ORDERITEMS
  • PACK
  • PAYBILLS
  • PRINT
  • QUICKVIEW
  • REASSIGN
  • REJECT
  • SHIP
  • SPECIALORDER
  • TRANSFORM
  • VIEW
  • XEDIT

const afterSubmit = (scriptContext) => {
            try {
                let fulfillment = scriptContext.newRecord;
                let fulfillmentId = fulfillment.id;
                let shipStatus = fulfillment.getValue({ fieldId: 'shipstatus' });
                let asnSynced = fulfillment.getValue({ fieldId: 'custbody_jj_b2b_asn_synced' });
                if (scriptContext.type == 'ship' || (scriptContext.type == 'edit' && shipStatus == 'C' && !asnSynced)) {
                    let customerId = fulfillment.getValue({ fieldId: 'entity' });
                    if (!customerId) {
                        return;
                    }
                   //Remaining code;
                }
             } catch (mainErr) {
                log.error('Error @ afterSubmit', mainErr);
             }
        };

Leave a comment

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