// 2.0 /** * @NScriptType UserEventScript * @NApiVersion 2.x */ define(["N/ui/serverWidget", "N/runtime"], function (ui, runtime) { var exports = {}; function beforeLoad(scriptContext) { showBonusEligibility(scriptContext.form); } function showBonusEligibility(form) { // Doesn't make sense to modify the form if the if (!wasTriggeredFromUi(runtime.executionContext)) { return; } // Continue with form modification... } function wasTriggeredFromUi(context) { // Context can be compared to enumeration from runtime module return (context === runtime.ContextType.USER_INTERFACE); } exports.beforeLoad = beforeLoad; return exports; });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter