search.duplicates(options)
The content in this help topic pertains to SuiteScript 2.0.
Method Description |
Performs a search for duplicate records based on the account's duplicate detection configuration. This method also includes a promise version, search.duplicates.promise(options). For more information about promises, see Promise Object.
Important:
This API works only for records that support duplicate record detection (for example, customer, lead, prospect, contact, partner, and vendor records). For more information about duplicate record detection, see Duplicate Record Detection. |
Returns |
search.Result[] that contains the duplicate records Results are limited to 1000 rows. If there are no search results, this method returns |
Supported Script Types |
Client and server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
10 units |
Module |
|
Since |
2015.2 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
enum |
Required |
The search type that you want to check for duplicates. Use the search.Type enum for this parameter. The type you specify must correspond to a record type that supports duplicate record detection (for example, customer, lead, prospect, contact, partner, and vendor records). |
2015.2 |
|
Object |
Optional |
A set of key/value pairs used to detect duplicates. The keys are internal ID names of the fields used to detect duplicates. You can specify fields such as companyname, email, name, phone, address1, city, state, and zipcode. For example, to detect duplicates based on the value of the email field, use Use this parameter to specify the fields (and their values) to use to detect duplicates. If you are searching for duplicates based on fields that appear on a certain record type, this parameter is required. If you are searching for duplicates of a specific record (of the specified type), use the options.id parameter instead. |
2015.2 |
|
number |
Optional |
Internal ID of an existing record. Use this parameter to specify a record to detect duplicates of. The duplicate record detection settings in the account determine which fields are used to detect duplicates of the specified record. If you are searching for duplicates of a specific record (of the specified type), this parameter is required. If you are searching for duplicates based on fields that appear on a certain record type, use the options.fields parameter instead. |
2015.2 |
Errors
Error Code |
Message |
Thrown If |
---|---|---|
|
{1}: Missing a required argument: {2} |
Required parameter is missing. |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/search Module Script Samples.
//Add additional code
...
// Search for duplicates of a specific record using the options.id
// parameter
var duplicatesOfRecord = search.duplicates({
type: search.Type.CONTACT,
id: 425
});
// Search for duplicates based on specific fields on a record type
// using the options.fields parameter
var duplicatesUsingFields = search.duplicates({
type: search.Type.CONTACT,
fields: {
'email' : 'sample@test.com'
}
});
...
//Add additional code