I'm trying to create an Inventory Adjustment based...
# suitescript
n
I'm trying to create an Inventory Adjustment based off an Assembly Build. So far so good but when I try and link the related Inventory Adjustment back to the Assembly Build I get an error
Copy code
// Create Inventory Adjustment
var inventoryAdjustmentId = createInventoryAdjustment()

// Link Assembly Build to Inventory Adjustment
assemblyBuildRecord.setValue({
   fieldId: "custbody_linked_inv_adj",
   value: inventoryAdjustmentId,
   ignoreFieldChange: true,
});
assemblyBuildRecord.save();
The Custom Field
custbody_linked_inv_adj
is a Transaction Body Field of Type: List/Record and List/Record: Transaction. I get the following Error,
Copy code
{
  "type": "error.SuiteScriptError",
  "name": "YOU_CANNOT_CALL_1_METHOD_ON_SUBRECORD_FIELD_2",
  "message": "You cannot call getFieldValue method on subrecord field: inventorydetail.",
  "cause": {
    "type": "internal error",
    "code": "YOU_CANNOT_CALL_1_METHOD_ON_SUBRECORD_FIELD_2",
    "details": "You cannot call getFieldValue method on subrecord field: inventorydetail.",
    "userEvent": "aftersubmit",
    "notifyOff": false
  },
  "id": "",
  "notifyOff": false,
  "userFacing": false
}
Any thoughts?
s
My thought is the error has nothing to do with linking to the assembly build and it's how you are handling inventory detail in
createInventoryAdjustment()
Actually what is the context this is running? Perhaps there is a different user event firing on
afterSubmit
on assembly builds that is causing this problem.
n
context is UserEventType.CREATE
Very possible, I'll check the other scripts (4)
I find it strange that there is no conflict or error unless I try to link,
s
if this is running in a user event, then it should not trigger another user event
n
Great Suggestion, turns out there is another user event script running that I suspect is causing a conflict.
139 Views