What caused the error: TypeError: Cannot find func...
# ask-stanley-ai
j
What caused the error: TypeError: Cannot find function selectLine in object standard record.
c
AI generated answer (using internal Slack threads):
The error
TypeError: Cannot find function selectLine in object standard record
is caused because the
selectLine
function is only available when a record is loaded in dynamic mode. If you are loading a record in standard mode, this function will not be available. For example, if you are loading a record with
record.load({type: 'type', id: 'id', isDynamic: false})
, the
selectLine
function will not be available. If
isDynamic
is set to
true
, then you can use it. If you are working with a scheduled script and you are not in dynamic mode, you should use
N/record
methods instead of
N/currentRecord
methods. This means no selecting lines, no
setCurrentLineValue
, no
commitLine
. Instead, use
rec.setSublistValue()
. For example:
Copy code
javascript
salesOrder.setSublistValue({
    sublistId: 'item',
    fieldId: 'item',
    line: 1,
    value: itemId
});

salesOrder.setSublistValue({
    sublistId: 'item',
    fieldId: 'quantity',
    line: 1,
    value: quantity
});
Also, remember that line indexes start at 0, not 1. So, if you are still getting errors, try changing the line numbers accordingly. ****** 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.901355565
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.838850379
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83500129
Please provide your feedback on this answer.