I am encountering an error when saving an item rec...
# ask-stanley-ai
c
I am encountering an error when saving an item receipt that is created from an outsourced manufacturing PO: You cannot call getFieldValue method on subrecord field: inventorydetai
c
AI generated answer (using internal Slack threads):
Based on the conversations, the error you're encountering when saving an item receipt created from an outsourced manufacturing PO is likely due to the way you're handling the inventory detail subrecord in your SuiteScript code. The error message
You cannot call getFieldValue method on subrecord field: inventorydetail
suggests that you're trying to call the
getFieldValue
method on a subrecord field, which is not allowed in SuiteScript. Instead, you should be using the
getSublistSubrecord
method to access the inventory detail subrecord. Here's a sample code snippet that was shared in the conversations:
Copy code
javascript
var objRecord = record.load({
    type: record.Type.ITEM_RECEIPT,
    id: itemrcpt,
    isDynamic: false,
});
var objSubRecord = objRecord.getSublistSubrecord({
    sublistId: 'item',
    fieldId: 'inventorydetail',
    line: i
});
var numLines2 = objSubRecord.getLineCount({
    sublistId: 'inventoryassignment'
});
for (var j = 0; j < numLines2; j++) {
    var serialnumber = objSubRecord.getSublistValue({
        sublistId: 'inventoryassignment',
        fieldId: 'receiptinventorynumber',
        line: j
    });
    var Subrecordquantity = objSubRecord.getSublistValue({
        sublistId: 'inventoryassignment',
        fieldId: 'quantity',
        line: j
    });
    dialog.alert({
        title: 'Alert',
        message: serialnumber
    });
}
In this code, the
getSublistSubrecord
method is used to access the inventory detail subrecord. Then, the
getLineCount
method is used to get the number of lines in the inventory assignment sublist, and the
getSublistValue
method is used to get the values of the
receiptinventorynumber
and
quantity
fields for each line. Remember to replace
itemrcpt
and
i
with the actual ID of the item receipt and the line number you're working with, respectively. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.904602051
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.853149414
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.852111876
Please provide your feedback on this answer.