• : 1-877-596-8218
  • : sales@aecc.ca
# # #
#

How to Generate a Pop up Warning In NetSuite.

How to Generate a Pop up Warning In NetSuite

This article is relevant when you are looking to have an alert pop-up when some conditions meet on save of the Netsuite record.

Background

There are different trigger types of Client side scripts that we can add the alert. For example, if you want pop up an alert when on save of the record, you can use the saveRecord trigger type. When you want to validate the field that user enters and pop up an alert when the field validation failed, you can use the Field change trigger type.

In this example, when the Sales Order has an item of the list Internal IDs [ 5,6,7 ] , on save of the record, the script will pop ups an alert to remind the user to add the partner.

function onSaveTriggerPopup (){

listText = [5,6,7]; // Change list of Internal Ids in this Array
//get the number of line items in the SO item sublist
var numLine = nlapiGetLineItemCount('item', 'item');
//Define the boolean variable to record if there is a match found between internal ID list and the line item internal ID
var found = false;
//loop over each line item to check item internal ID
for (var i = 1; i <= numLine; i++) {
	//get line item internal ID
	var ID = nlapiGetLineItemValue('item', 'item', i);
	//check if current item internal ID is inside the internal ID list
	//This will return '-1' if no match found, and return the index number for a match
	var returnCode = listArray.indexOf(ID);
	//check if a match found, if this is true, the script will set bool variable found to be true
	if (returnCode != '-1') {
		found = true;
		nlapiLogExecution('DEBUG', 'found an line item with internalID: ' + ID, '-');
		break;
	}
}
//pop-up alert window if a match found
if (found == true) {
	alert("Have you added a partner?");
}

}

 

If one or more Items on the current SO are listed in the script parameter item list, the following alert will pop up.