If the record was created 24 hours before, restrict the user from editing some of the fields and sublists. For that, we can use a client script to disable the fields and sublists in the PageInit entry point based on the conditions. The sample codes are given below,
pageInit: function (scriptContext) {
try {
let currentRecord = scriptContext.currentRecord;
modeOfSalesOrderRecord = scriptContext.mode;
if (modeOfSalesOrderRecord == 'edit') {
let recordId = currentRecord.id;
console.log('recordId', recordId);
restrictSalesTeamDetails = getSalesOrderCreateDetails(recordId) // to check whether ther sales rder record was created before 24 hours ago. If the record is created 24 hours before, then the result is true.
if (checkForParameter(restrictSalesTeamDetails)) {
scriptContext.currentRecord.getField({ fieldId: 'salesgroup' }).isDisabled = true; // disabled the field CHOOSE TEAM
scriptContext.currentRecord.getField({ fieldId: 'syncsalesteams' }).isDisabled = true; // disabled the field UPDATE CUSTOMER
let sublistId = scriptContext.currentRecord.getSublist({
sublistId: 'salesteam'
});
sublistId.getColumn({ // disabled the column EMPLOYEE
fieldId: 'employee'
}).isDisabled = true;
sublistId.getColumn({ // disabled the column SALES ROLE
fieldId: 'salesrole'
}).isDisabled = true;
sublistId.getColumn({ // disabled the column PRIMARY
fieldId: 'isprimary'
}).isDisabled = true;
sublistId.getColumn({ // disabled the column CONTRIBUTION %
fieldId: 'contribution'
}).isDisabled = true;
}
}
} catch (e) {
console.log('error@pageInit', e)
console.error('error@pageInit', e)
}
},
