Jahangir Bin Tayyab Hussain
09/09/2024, 12:37 PMCeligo AI
09/09/2024, 12:37 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. ****** It seems like your script is being triggered twice, which is why the amount is being added twice. This could be due to the context in which your script is running. In SuiteScript, scripts can be triggered in different contexts such as 'create', 'edit', 'view', 'xedit', 'store', etc. If your script is running on 'edit' context, it might be triggered twice - once when the item is added to the cart and once when the cart is updated. You can add a condition in your script to check the context and only run the script when the context is 'create'. Here's a sample code snippet:
javascript
function yourFunction(scriptContext) {
if (scriptContext.type === scriptContext.UserEventType.CREATE) {
// Your code here
}
}
This will ensure that your script only runs when an item is added to the cart, not when the cart is updated.
Also, make sure that your script is not deployed twice in different script deployments. Check your script deployments and ensure that there's only one active deployment for your script.
If the issue persists, you might want to check if there are any other scripts or workflows that might be triggering your script. You can do this by going to Customization > Scripting > Scripted Records, and then clicking on the relevant record type to see all the scripts and workflows associated with it.
Remember to thoroughly test your changes in a sandbox environment before deploying them to production.Celigo AI
09/09/2024, 12:37 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.838477433
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.834003747
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.829197407
Celigo AI
09/09/2024, 12:37 PM