Show a popup window to add the reason while changing the Price level field value

Code section to enter the reason when the user changes the price level field value to ‘Custom’. Use the below-mentioned code section in the ‘fielsChanged’ entry point of the client script

fieldChanged: function (scriptContext) {

    try {

        if ((scriptContext.sublistId == 'item') && (scriptContext.fieldId == 'price')) {

            let currentRecord = scriptContext.currentRecord;
            let currentLine = scriptContext.line

            let newPriceLevelValue = currentRecord.getCurrentSublistValue({
                fieldId: 'price',
                sublistId: 'item',
                line: currentLine,
            });
           if ((newPriceLevelValue == PRICE_LEVEL_CUSTOM)) {

                let popUpWindow = '';
                while (!popUpWindow) {
                    popUpWindow = prompt("Reason for changing the 'Price Level'");
                }
                ;
                let changingReason = popUpWindow;

                if (checkForParameter(changingReason)) {
                    currentRecord.setCurrentSublistText({
                        fieldId: 'custcol_jj_so_price_level_chang_reasn',
                        sublistId: 'item',
                        text: changingReason
                    })
                }
            } else {
                currentRecord.setCurrentSublistText({
                    fieldId: 'custcol_jj_so_price_level_chang_reasn',
                    sublistId: 'item',
                    text: ''
                })
            }
        }
    } catch (e) {
        console.log('error@fieldChanged', e)
    }
},

Leave a comment

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