dennysutanto
04/26/2025, 5:03 PMCeligo AI
04/26/2025, 5:04 PMAI generated answer (using internal Slack threads):****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** The
lineInit
function in SuiteScript is triggered every time a line item is initialized. This includes when a line item is added, edited, or focused on in the UI. Therefore, if you're seeing the lineInit
function being triggered twice when you click 'add' on a sales order line item, it's likely because the line is being initialized twice - once when the line is added, and once when the line is focused on or edited.
If you need to differentiate between adding a new line item and editing an existing one, you could consider using a global variable to track the state. In the lineInit
function, you could check if the item field is blank. If it is, it's a new line item and you could set the global variable to 'Add'. If it's not blank, it's an existing line item and you could set the global variable to 'Edit'. Then, in your validateLine
function, you could check the value of the global variable to determine whether the line item is being added or edited.
However, please note that this approach might not work if you're using the 'Add Multiple' button to add multiple lines at once. The 'Add Multiple' button does not trigger the validateLine
function, so any logic in that function will not be executed when lines are added this way. If you need to run SuiteScript when using the 'Add Multiple' button, you might need to use the sublistChanged
entry point instead. Alternatively, you could consider disabling the 'Add Multiple' option on the custom form.Celigo AI
04/26/2025, 5:04 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.832201898
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.825740099
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.820963442
Celigo AI
04/26/2025, 5:04 PM