Hi Experts, I am trying to implement suiteanswer I...
# suiteflow
r
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). Can you please check the script and help me correct it? 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} Thanks /** * u/NApiVersion 2.x * u/NScriptType UserEventScript * u/NModuleScope SameAccount */ define(['N/record'], function(record) { /** * Function definition to be triggered before record is loaded. * * u/param {Object} scriptContext * u/param {Record} scriptContext.newRecord - New record * u/param {string} scriptContext.type - Trigger type * u/param {Form} scriptContext.form - Current form * u/Since 2015.2 */ function beforeLoad(scriptContext) { } /** * Function definition to be triggered before record is loaded. * * u/param {Object} scriptContext * u/param {Record} scriptContext.newRecord - New record * u/param {Record} scriptContext.oldRecord - Old record * u/param {string} scriptContext.type - Trigger type * u/Since 2015.2 */ function beforeSubmit(scriptContext) { } /** * Function definition to be triggered before record is loaded. * * u/param {Object} scriptContext * u/param {Record} scriptContext.newRecord - New record * u/param {Record} scriptContext.oldRecord - Old record * u/param {string} scriptContext.type - Trigger type * u/Since 2015.2 */ function afterSubmit(scriptContext) {
Copy code
// 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 Vendor Bill in the Custom Record Created });
Copy code
// 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 }; });