Pop-up alert when IF changed to Shipped status

REQUIREMENT

The client needs to show a Pop message with the shipping note value when the shipping status is changed to Shipped in the item fulfillment record.

SOLUTION

function fieldChanged(scriptContext) {
            try {

                let currentRec = scriptContext.currentRecord
                let shippingNote = currentRec.getValue("custbody6")

                let createdFrom = currentRec.getValue({
                    fieldId: 'createdfrom'
                });

                let salesorderSearchObj = search.create({
                    type: "salesorder",
                    filters:
                    [
                       ["type","anyof","SalesOrd"], 
                       "AND", 
                       ["internalidnumber","equalto",createdFrom], 
                       "AND", 
                       ["mainline","is","T"]
                    ],
                    columns:
                    [
                       search.createColumn({name: "internalid", label: "Internal ID"})
                    ]
                 });
                 let searchResultCount = salesorderSearchObj.runPaged().count;


                 if(searchResultCount>0){
                    if (checkForParameter(shippingNote)) {
                        if (scriptContext.fieldId === 'shipstatus') {
    
                            if (currentRec.getValue({ fieldId: 'shipstatus' }) === 'C') {
                                let options = {
                                    title: 'Shipping Note',
                                    message: '<span style="color: red; font-weight: bold;font-size: 20px;">' + shippingNote + '</span>',
                                };
                                dialog.alert(options)
                            }
                        }
                    }
                 }

            }
            catch (err) {
               log.error("error@fieldChanged", err)
            }
        }

Leave a comment

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