Hello, i have a question: in a UserEvent script, ...
# ask-stanley-ai
t
Hello, i have a question: in a UserEvent script, do you know why in XEDIT the
getLineCount
will return 0 but in EDIT, it will work well and return the right number of lines ?
function _beforeSubmit(scriptContext) {
let recOpp = scriptContext.newRecord;
let opType = scriptContext.type;
let itemCount = recOpp.getLineCount({sublistId: 'item'});
c
AI generated answer (using internal Slack threads):
The
getLineCount
function in a UserEvent script may return 0 in XEDIT because the XEDIT event is triggered when a record is edited, but before it is submitted. At this point, the changes are not yet committed to the database, so the line count of the sublist may not be updated yet. On the other hand, in the EDIT event, the changes have been committed to the database, so the
getLineCount
function can return the correct number of lines. Here is a simplified explanation of the script execution context: - XEDIT: Triggered when a record is edited, but before it is submitted. Changes are not yet committed to the database. - EDIT: Triggered after a record is edited and the changes are committed to the database. So, if you're trying to get the line count in a UserEvent script, it would be more reliable to do so in the EDIT context rather than the XEDIT context. ****** 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.850749791
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.847365737
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.846195579
Please provide your feedback on this answer.