RE: Copying custom reject reason on vendor bill
Hi Experts,
I am trying to implement suiteanswer ID 74548 and have created a custom record to capture vendor bill rejection reason as our approvers have employee centre role,
which only allows view access to the bills. I am able to capture the reason correctly but after modifying the sample script to suit vendor bill, it is still erroring out at submitFields, due to incorrect inputs. All I want to do is it get the rejection reason from the custom record and update it on the current vendor bill rejection reason (custom field added on the screen).
Error:
{“type”:”error.SuiteScriptError”,”name”:”SSS_MISSING_REQD_ARGUMENT”,”message”:”submitFields: Missing a required argument: id”,”stack”:[“createError(N/error)”,”afterSubmit(/SuiteScripts/Rej Reason Test.js:60)”,”createError(N/error)”],”cause”:{“name”:”SSS_MISSING_REQD_ARGUMENT”,”message”:”submitFields: Missing a required argument: id”},”id”:””,”notifyOff”:false,”userFacing”:true}
Can you please check the script and help me correct it?
Thanks
/** * @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: { custrecord165: 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 }; });
just a quick peek. I am assuming that the fieldID on the Vendor bill needs to be the field designation on line 105.. ? I am attempting my self.