Jira Code: SC-47
This is a mass update script to create Payment record from all the open invoices.
Mass Update Script
/**
* @NApiVersion 2.x
* @NScriptType MassUpdateScript
* @NModuleScope SameAccount
*/
/*******************************************************************************
* CLIENTNAME:SKN Complex
* SC-47
* bulk clear outstanding balances from Debtors
* **************************************************************************
* Date : 18-06-2019
*
* Author: Jobin & Jismi IT Services LLP
* Script Description : This script is to create payment record from open invoices.
* Date created : 18-06-2019
*
* REVISION HISTORY
*
* Revision 1.0 ${18-06-2019} nd : created
*
*
******************************************************************************/
define(['N/record', 'N/search'],
/**
* @param {record} record
* @param {search} search
*/
function(record, search) {
/**
* Definition of Mass Update trigger point.
*
* @param {Object} params
* @param {string} params.type - Record type of the record being processed by the mass update
* @param {number} params.id - ID of the record being processed by the mass update
*
* @since 2016.1
*/
function each(params) {
try {
var record_id = params.id //invoice id
var fieldLookUp = search.lookupFields({
type: search.Type.INVOICE,
id: record_id,
columns: ['trandate']
});
log.debug('fieldLookUp.trandate', fieldLookUp.trandate)
log.debug('fieldLookUp', fieldLookUp)
var objRecord = record.transform({
fromType: record.Type.INVOICE,
fromId: record_id,
toType: record.Type.CUSTOMER_PAYMENT,
isDynamic: true,
});
log.debug('objRecord', objRecord)
objRecord.setText({
fieldId: 'trandate',
text:fieldLookUp.trandate,
// ignoreFieldChange: true
});
objRecord.setValue({
fieldId: 'account',
value: 1,
// ignoreFieldChange: true
});
var recordId=objRecord.save();
log.debug('recordId', recordId)
} catch (err) {
log.debug("err", err)
}
}
return {
each: each
};
});