Merge Revenue Elements Using Internal IDs

The following sample adds the internal IDs of several revenue element records to an array. It calls recognition.create(options) to create a merge task for revenue element records, uses the array as the list of revenue element records to merge, and submits the merge task. The sample also checks the status of the merge task.

If you run this sample code in your account, be sure to use the internal IDs of valid revenue element records in your account.

Note:

This sample script uses the require function so that you can copy it into the SuiteScript Debugger and test it. You must use the define function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.

          /**
 * @NApiVersion 2.x
 */

require(['N/task/accounting/recognition'], function(recognition){
    var elementsList = [];
    elementsList.push(401);
    elementsList.push(402);

    var recognitionTask = recognition.create({
        taskType: recognition.TaskType.MERGE_ELEMENTS_TASK
    });
    recognitionTask.elements = elementsList;
    var taskStatusId = recognitionTask.submit();

    var mergeTaskState = recognition.checkStatus({
        taskId: taskStatusId
    });

    log.debug('Submission ID = ' + mergeTaskState.submissionId);
    log.debug('Resulting Arrangement ID = ' + mergeTaskState.resultingArrangement);
    log.debug('status = ' + mergeTaskState.status);
}); 

        

General Notices