Jars
09/11/2024, 7:33 AMCeligo AI
09/11/2024, 7:33 AMAI generated answer (using internal Slack threads):Yes, there can be an infinite loop when a User Event (UE) script calls a Scheduled Script and it updates the same record where the UE is deployed. This is because the UE script triggers on record submit, and if the Scheduled Script updates the same record, it will trigger the UE script again, creating a loop. To avoid this, you can use a flag field on the record to indicate whether the update is coming from the Scheduled Script or not. Before the Scheduled Script updates the record, it sets the flag. The UE script then checks this flag before executing, and if it's set, it doesn't run its logic and resets the flag. Here's a simplified example of how this could be implemented: UE Script:
javascript
function userEventAfterSubmit(context) {
var record = context.newRecord;
var isUpdateFromScheduledScript = record.getValue('custrecord_update_from_ss');
if (isUpdateFromScheduledScript) {
record.setValue('custrecord_update_from_ss', false);
return;
}
// Rest of the UE script logic...
}
Scheduled Script:
javascript
function execute(context) {
var recordId = // get the record id to update
var record = record.load({
type: 'customrecord_my_record',
id: recordId
});
record.setValue('custrecord_update_from_ss', true);
// make other updates...
record.save();
}
In this example, custrecord_update_from_ss
is a custom checkbox field on the record that is used as a flag to indicate whether the update is coming from the Scheduled Script.
******
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
09/11/2024, 7:34 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.846592
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.839689434
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.838387
Celigo AI
09/11/2024, 7:34 AM