Jack R
12/17/2024, 4:12 PM/**
* @NApiVersion 2.x
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define(['N/currentRecord'], function(currentRecord) {
/**
* Executes when the page is initialized.
* @param {Object} context - Script execution context
* @param {Record} context.currentRecord - Current form record
* @param {string} context.mode - Mode in which the form is loaded (create, copy, edit, etc.)
*/
function pageInit(context) {
var rec = context.currentRecord;
// Check if the form is in "copy" mode
if (context.mode === 'copy') {
var lineCount = rec.getLineCount({ sublistId: 'price1' });
// Iterate through the Price Levels sublist and clear the price field
for (var i = 0; i < lineCount; i++) {
rec.selectLine({ sublistId: 'price1', line: i });
rec.setCurrentSublistValue({
sublistId: 'price1',
fieldId: 'price',
value: 0 // Clear pricing by setting it to 0
});
rec.commitLine({ sublistId: 'price1' });
}
}
}
return {
pageInit: pageInit
};
});
battk
12/17/2024, 4:13 PMJack R
12/17/2024, 7:59 PM