Requirement
The amount shown in transactional lines in all Invoice/PA(sales order) needs to be masked so no one can change it.
If a user attempts to change the amount of an invoice or payment agreement record when it is created or edited, the amount value must not be changed through the user interface.
Solution
/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
*/
define(['N/currentRecord', 'N/record', 'N/ui/serverWidget'],
/**
* @param{currentRecord} currentRecord
* @param{record} record
* @param{serverWidget} serverWidget
*/
(currentRecord, record, serverWidget) => {
const beforeLoad = (scriptContext) => {
try {
var currentRec = scriptContext.form
var sublist = currentRec.getSublist({
id: 'item'
});
var objColumn = sublist.getField({
id: 'amount'
});
objColumn.updateDisplayType({
displayType: serverWidget.FieldDisplayType.DISABLED
});
} catch (e) {
log.debug('Error@BeforeLoad', e)
}
}
return {beforeLoad}
});