Perform Mass Update on Transactions with Custom Line Item Field as Search Criteria

Scenario

A user requires to perform a mass update to Transactions with Custom Line Item Field included as Search Criteria.

Solution

As Mass Update can only be done on body fields, an alternative is to deploy a Scheduled Script:

  1. Create a Saved Search
  • Create a saved search with the criteria similar to your mass update script.

     2. Create a Scheduled Script

  1. In the Scheduled script, load the saved search that you have created by utilizing SuiteScript 1.0 nlapiLoadSearch(type, id) pr SuiteScript 2.0 search.load(options) 
  2. Loop through the search results, get the record ID and utilize your original script inside the loop.
SuiteScript 2.0
var mySearch = search.load({ id: 'customsearch_my_search' }); var res = mySearch.run(); result.each(function(row){ var rec_id = row.getValue({name:'internalid'}) var billRec = record.load({ type: record.Type.VENDOR_BILL, id: rec_id, isDynamic: true, }); var totalCount = billRec.getLineCount({ sublistId: 'item' }); for (var index = 0; index < totalCount; ++index) { // Your intended update code } billRec.save({ enableSourcing: true, ignoreMandatoryFields: true }); })

3. Save the Scheduled Script and execute it.

Leave a comment

Your email address will not be published. Required fields are marked *