- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2020 03:07 AM
Hi,
I'm curiouse how can I create loop over workflow by script. I've got run script thats sends email and weekly timer. I wanna loop it four times until end of the month and then go to begining. I didn't find any out-of-the-box solution in the way of activities for loop. Below is my run script to send emails
var callers = [];
var encodedString = 'active=true^state=-5';
var gr = new GlideRecord("change_request");
gr.addQuery(encodedString);
gr.query();
while (gr.next()) {
callers.push(gr.requested_by.email.toString());
}
var arrayUtil = new ArrayUtil();
callers = arrayUtil.unique(callers);
for(var i = 0; i < callers.length; i++){
gs.eventQueue('reminder.event', null, callers[i], '');
}
Maybe there is another simpler way to solve this ?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2020 09:13 PM
Hi
If I stay on a scheduled job, there are more options.
a) you create different schedulef jobs and they run on different schedules (not sure, if you can configure a workflow to only run at month end)
OR
b) you handle your scheduling logic INSIDE ONE scheduled job in a script which runs DAILY , e.g. To check the last day of the month and then run the specific logic.
Personally I would choose option b)
This would keep all logic regarding your one requirement one one place.
And remember, that workflows are not intended to run forever.
Let me know if that answered your question and mark my answer as correct and helpful.
BR Dirk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2020 02:21 PM
Hi
To be honest, if you just send the same notification every 7 days, like I see in your code, you just need to put your code to the scheduled job.
That's it.
Let me know if that answered your question and mark my answer as correct and helpful.
BR Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2020 03:40 PM
Hi
For automatize send emails every 7 days your solution suits well but my task require more functionality beside weekly reminder e.g. send email last day on month or send email after changing form status.
Is that possible manage by Scheduled Job only? I supose not, am I right?
I need find put together those functionality in one workflow, is that possible ?
Or maybe other solution can manage my issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2020 09:13 PM
Hi
If I stay on a scheduled job, there are more options.
a) you create different schedulef jobs and they run on different schedules (not sure, if you can configure a workflow to only run at month end)
OR
b) you handle your scheduling logic INSIDE ONE scheduled job in a script which runs DAILY , e.g. To check the last day of the month and then run the specific logic.
Personally I would choose option b)
This would keep all logic regarding your one requirement one one place.
And remember, that workflows are not intended to run forever.
Let me know if that answered your question and mark my answer as correct and helpful.
BR Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2020 01:16 PM
thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2020 02:02 PM