Created
November 15, 2022 16:59
-
-
Save marvac/e3b5ab51ebaa1af32b01f95eb3e4ece9 to your computer and use it in GitHub Desktop.
NetSuite: Display an alert if an item on the transaction is inactive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* transaction.clientscript.js | |
* | |
* @NScriptName Custom Client Script For Transactions | |
* @NScriptType ClientScript | |
* @NApiVersion 2.x | |
*/ | |
define(["N/log", "N/ui/dialog"], function (log, alert) { | |
var exports = {}; | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.saveRecord = exports.pageInit = void 0; | |
function saveRecord(context) { | |
var currentRecord = context.currentRecord; | |
var itemCount = currentRecord.getLineCount({ | |
sublistId: "item", | |
}); | |
for (var i = 0; i < itemCount; i++) { | |
var hasInactive = currentRecord.getSublistValue({ | |
sublistId: "item", | |
fieldId: "custcol_isinactive", | |
line: i, | |
}); | |
if (hasInactive) { | |
alert.alert({ | |
title: "Inactive Item", | |
message: "The item on line ".concat(i + 1, " is inactive and the transaction cannot be saved until removed or replaced."), | |
}); | |
return false; | |
} | |
} | |
return true; | |
} | |
exports.saveRecord = saveRecord; | |
return exports; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment