To workaround the problem, one can use the combination of nlapiSearchDuplicate and nlapiCreateError.
nlapiSearchDuplicate will perform a search for duplicate records based on the account's Duplicate Detection configuration. If a record already exists, then an error will be thrown to prevent the record from being saved in NetSuite.Below is a sample snippet to use that is to be deployed on before submit of Customer record:
The following example performs a duplicate detection search for all customer records using the "email" field of the currently submitted record.function detectDup(){
var fldMap = new Array();
fldMap['email'] = nlapiGetFieldValue('email');
var duplicateRecords = nlapiSearchDuplicate( 'customer', fldMap );
var err = nlapiCreateError('E500', 'Record cannot be saved, duplicate detected');
throw err;
}
}
No comments:
Post a Comment