Show Alert and Prevent Save when Duplicate Customer Record is Created

With Duplicate Detection Feature the users are notified of potential duplicates upon record creation.

When creating a new record and entering matching data in fields that are set up as duplicate criteria, a warning is shown at the top of the page with a link to the potential duplicates. 

Although NetSuite can detect these duplicates, it does not prevent a new record from being saved.

 

Solution

Create a Client Script with Save Record Function that would check if there are any records already existing with these details and show a popup message to prevent from saving.

 

Script code example:

 

function detectDuplicate_OnSave()

{

var fldMap = new Array();

var email = nlapiGetFieldValue(’email’);

fldMap[’email’] = email;

var duplicateRecords = nlapiSearchDuplicate( ‘customer’, fldMap );

if (duplicateRecords != null)

{

alert(‘Record cannot be saved, duplicate detected’);

return false;

}

else

return true;

}

 

Create the Client Script record in NetSuite through Customization > Scripting > Scripts > New > Client Script. 

  • Scripts tab: select the Script File = the name of the script you have uploaded in step 1 and in Save Record Function = detectDuplicate_OnSave
  • Deployments tab: Applies To = Customer, Status = Released, Select Audience

Leave a comment

Your email address will not be published. Required fields are marked *