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();

Rookie Asked on September 1, 2020 in SuiteScript.
Add Comment
1 Answer(s)

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

 

Intermediate Answered on September 2, 2020.

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();
on September 3, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor