Merge Revenue Arrangements Using an Ad-Hoc Search

The following sample creates an ad-hoc search for revenue element records. It obtains the first 50 results, obtains the value of the elementsList field from each record in the result set, and adds the values 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 elements records to merge, and submits the merge task. This sample also checks the status of the merge task and logs status information.

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', 'N/search'], function(recognition, search) {
    var elementsList = [];
    var rs = search.create({
        type: 'revenueelement',
        columns: [
            'internalid'
        ]
    }).run();

    var results = rs.getRange(0, 50);
    for (var i = 0; i < results.length; i++) {
        var id = result.getValue('elementsList');
        elementsList.push(id);
    }

    var t = recognition.create({
        taskType: recognition.TaskType.MERGE_ELEMENTS_TASK
    });
    t.elements = elementsList;
    t.revenueArrangementDate = new Date(2019, 1, 1);

    var taskId = t.submit();
    log.debug('Initial status: ' + res.status);
}); 

        

General Notices