Rookie
07/20/2021, 3:34 PM/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define(['N/record'],
function(record) {
/**
* Function definition to be triggered before record is loaded.
*
* @param {Object} scriptContext
* @param {Record} scriptContext.newRecord - New record
* @param {string} scriptContext.type - Trigger type
* @param {Form} scriptContext.form - Current form
* @Since 2015.2
*/
function beforeLoad(scriptContext)
{
}
/**
* Function definition to be triggered before record is loaded.
*
* @param {Object} scriptContext
* @param {Record} scriptContext.newRecord - New record
* @param {Record} scriptContext.oldRecord - Old record
* @param {string} scriptContext.type - Trigger type
* @Since 2015.2
*/
function beforeSubmit(scriptContext)
{
}
/**
* Function definition to be triggered before record is loaded.
*
* @param {Object} scriptContext
* @param {Record} scriptContext.newRecord - New record
* @param {Record} scriptContext.oldRecord - Old record
* @param {string} scriptContext.type - Trigger type
* @Since 2015.2
*/
function afterSubmit(scriptContext)
{
// Get the value of the Reject reason
var rejReason = scriptContext.newRecord.getValue({
fieldId: 'custrecord165' // Change this according to the internal id of the Field Reject Reason in the Custom Record Created
});
// Get the ID of the Vendor Bill Reject reason
var venbillID = scriptContext.newRecord.getValue({
fieldId: 'custrecord166' // Change this according to the internal id of the Field Reject Reason in the Custom Record Created
});
// populate the Reject Reason in the Vendor Bill Rejection Reason field
var id = record.submitFields({
type: record.Type.VENDOR_BILL,
id: venbillID,
values: {
custbody_rt_vendbill_rej_reason: rejReason //'testMSG01'
//custrecord165: 'testMSG'//rejReason // Change custbody1 to the internal id of the custom field Reject Reason in the Vendor Bill Record
},
options: {
enableSourcing: false,
ignoreMandatoryFields : true
}
});
}
return {
beforeLoad: beforeLoad,
beforeSubmit: beforeSubmit,
afterSubmit: afterSubmit
};
});battk
07/20/2021, 4:13 PMbattk
07/20/2021, 4:14 PMRookie
07/21/2021, 9:43 AMbattk
07/21/2021, 3:28 PMbattk
07/21/2021, 3:29 PMbattk
07/21/2021, 3:30 PMbattk
07/21/2021, 3:30 PM