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)
}
},