Scenario: Disable item sub list update option like add, edit, remove items from item sublist in Estimate,sales order and in other transaction records.
Client script is used for this scenario.
Code snippet:
// Declare a variable as global
var sublistEditFlag =false;
// On sublistChanged function,if sublist is item,then global variable is set to true. Sublistchanged function is triggered on create, edit or delete of sublist.
function sublistChanged(context) {
var currentRecord = context.currentRecord;
var magentoQuoteId = currentRecord.getValue('custbody_jj_adobe_quote_id');
if (magentoQuoteId) {
var sublistName = context.sublistId;
console.log("sublistName",sublistName);
if (sublistName === 'item')
sublistEditFlag =true;
}
}
// On save record function, check sublistEditFlag and call the error message
function saveRecord(scriptContext) {
try {
if(sublistEdit){
showErrorMessage('Estimate cannot be Edited');
return false;}
} catch (e) {
log.error("error @ saveRecord", e);}
// function for showing error message.
function showErrorMessage(msgText) {
var myMsg = msg.create({
title: "RECORD_EDIT_DISABLED",
message: msgText,
type: msg.Type.ERROR
});
myMsg.show({
duration: 6000
});
}