RE: Help on Error Code YOU_CANNOT_CALL_1_METHOD_ON_SUBRECORD_FIELD_2
I am running a User Event Script on Assembly Build create.
The User Event creates an Inventory Adjustment and returns the id on save. inventoryAdjustmentId
I would like to set a Custom Transaction field on the Assembly Build record (custbody_related_inv_adj
) to the id of the Inventory Adjustment Record.
I am getting the following Error that does not make sense to me.
I never call getFieldValue.
{"type":"error.SuiteScriptError", "name":"YOU_CANNOT_CALL_1_METHOD_ON_SUBRECORD_FIELD_2", "message":"You cannot call getFieldValue method on subrecord field: inventorydetail.", "stack":["anonymous(N/serverRecordService)","adjustInventory(file.js:170)"],
Everything works fine, able to create an Inventory Adjustment Record, and the related InventoryDetail subrecord.
As soon as I add the following, everything breaks,
// Set Inventory Adjustment Link on the Assembly Record recordModule.load({ type: recordModule.Type.ASSEMBLY_BUILD, id: context.newRecord.id, isDynamic: true }).setValue({ fieldId: ‘custbody_related_inv_adj’, value: inventoryAdjustmentId }).save();
Hi,
As the error says, Inventory Detail is a subrecord rather than a single value and there’s a really good article here that should help explain how you work with these records:
https://netsuite.custhelp.com/app/answers/detail/a_id/61062/kw/subrecords#subsect_1517632031
Please let me know if you need any further help once you’ve had a look at this article.
Thanks,
Chris
Chris, thanks for this great article. I’ve followed the link you provided as well as the dynamic version I posted. The User Event executes on Assembly Build create. Everything working just fine as long as I don’t add the last line of code.
// Set Inventory Adjustment Link on the Assembly Record recordModule.load({ type: recordModule.Type.ASSEMBLY_BUILD, id: context.newRecord.id, isDynamic: true }).setValue({ fieldId: 'custbody_related_inv_adj', value: inventoryAdjustmentId }).save();