If you want to show popup in NetSuite, we can use SweetAlert – JavaScript library that replaces the ‘alert’ function with customizable and elegant modals.
To use this functionality in your scripts, you need to use the library file ‘cdn.jsdelivr.net/npm/sweetalert2@10.10.1/dist/sweetalert2.all.min.js’ in the file cabinet. Load or call (sweetalert) this file into your script.
sweetalert.fire({
title: 'Price level changing reason',
input: 'select',
inputOptions: {
option1: 'Test Reason 1 test',
option2: 'Test Reason 2 reason is',
option3: 'Test Reason 3 test test',
},
inputPlaceholder: 'Select a Reason',
showCancelButton: true,
confirmButtonText: 'Submit',
cancelButtonText: 'Cancel',
inputValidator: (value) => {
// Validate the selected value if needed
let selectedReasonIs = sweetalert.getInput().selectedOptions[0].text;
if (!value) {
return 'You must select an option';
} else {
currentRecord.setCurrentSublistText({
fieldId: 'custcol_jj_so_price_level_chang_reasn',
sublistId: 'item',
text: selectedReasonIs
})
}
},
}).then((result) => {
console.log('resultCancel', result);
if (result.isConfirmed) {
const selectedValue = result.value;
console.log('Selected value: ', selectedValue);
// Perform further actions with the selected value
} else {
currentRecord.setCurrentSublistValue({
fieldId: 'price',
sublistId: 'item',
value: checkForParameter(currentLinePriceLevelValue) ? currentLinePriceLevelValue : PRICE_LEVEL_SALES_PRICE,
// ignoreFieldChange: true,
});
currentRecord.setCurrentSublistText({
fieldId: 'custcol_jj_so_price_level_chang_reasn',
sublistId: 'item',
text: checkForParameter(currentChangeReasonValue) ? currentChangeReasonValue : '',
// ignoreFieldChange: true,
});
alert("The price level value has not changed.");
}
});
This below code section will display the popup/ alert box when the script satisfies the condition. The sample for the popup window is given below. 