Search code examples
netsuitesuitecommerce

Merge records in SuiteScript 1.0


How can I merge 2 records in SuiteScript 1.0?

For example; I want to merge 2 customer records. The reason being we have many customers in our NetSuite backend that have not registered in our website. When they register NetSuite automatically creates a new customer instead of consolidating the existing customer. So I want to merge/consolidate those 2 records.

I have found nlapiMergeRecord(id, baseType, baseId, altType, altId, fields) but the help documentation says this function is now deprecated...

THIS API HAS BEEN DEPRECATED

This API is deprecated as of NetSuite Version 2015 Release 1. This function will no longer be supported as of Version 2016 Release 1.


Solution

  • The nlapiMergeRecord actually does/did something completely different to what you are looking for. It was used for merging a record with a template to create a "mail merge".

    For merging duplicate records in SuteScript 1.0 you can use the Job Manager APIs

    var manager = nlapiGetJobManager('DUPLICATERECORDS');
    var mergeJobRequest = manager.createJobRequest();
    mergeJobRequest.setEntityType(mergeJobRequest.ENTITY_LEAD);
    mergeJobRequest.setMasterSelectionMode(mergeJobRequest.MASTERSELECTIONMODE_CREATED_
       EARLIEST);
    mergeJobRequest.setRecords(duplicateRecords);
    mergeJobRequest.setOperation(mergeJobRequest.OPERATION_MERGE);
    jobId = manager.submit(mergeJobRequest);