Shelby Owens
12/05/2024, 6:26 PMCeligo AI
12/05/2024, 6:27 PMAI generated answer (using internal Slack threads):The error you're receiving is because the
selectNewLine
function is not available in a User Event script. This function is part of the dynamic record API and is typically used in client scripts. In a User Event script, the record is not in dynamic mode.
To add a new line to a sales order in a User Event script, you should use the setSublistValue
method. Here's an example of how you can do this:
javascript
var lineCount = record.getLineCount({sublistId: 'item'});
record.setSublistValue({sublistId: 'item', fieldId: 'item', line: lineCount, value: itemId});
record.setSublistValue({sublistId: 'item', fieldId: 'quantity', line: lineCount, value: quantity});
In this example, itemId
and quantity
are the values you want to set for the new line. The line
parameter for setSublistValue
is zero-based, so if you want to add a new line, you should use the current line count as the line number.
Please note that modifying records in a beforeSubmit User Event script can have performance implications, as it can double the save time of a record. It's also important to be aware that changes made in a beforeSubmit script are not visible to the user until after the record is saved.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
12/05/2024, 6:27 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.870000422
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.864421844
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851384163
Celigo AI
12/05/2024, 6:27 PM