
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
I have a very simple flow to trigger a notification. The flow's trigger is a daily schedule.
The flow's first step is to lookup records using a GlideRecord query. The script used is
var contracts = [];
var grAstContract = new GlideRecord('ast_contract');
grAstContract.addActiveQuery();
grAstContract.addNotNullQuery('ends');
grAstContract.addNotNullQuery('u_notice_period');
grAstContract.addNotNullQuery('contract_administrator');
grAstContract.query();
while (grAstContract.next()) {
var gdt = new GlideDate(grAstContract.ends);
gdt.addDays((grAstContract.u_notice_period * -1) - 30);
if (gdt.getDate().getValue() <= new GlideDate().getValue()) {
contracts.push(grAstContract.sys_id.toString());
}
}
return contracts;
When I log the query and run in on the contracts table, there is a result of 2 records.
Next flow step is a for each item-loop and then send the notification.
The logic works, however only 1 notification is being sent.
It's not a data issue, the selected recipients are active and have an email configured.
I'm stuck and in need of help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Do they also have the email active? User records can be set to not receiving the email.
However: why do you use a GlideRecord query to get the records? Why not simply use conditions (active is true and several fields are not empty and end date is 30 days from now). Those are simple conditions which make it a lot easier to maintain the flow, even after you aren't with the company any more.
For troubleshooting: check the flow execution log. It may show errors.
Also: what are your settings on the 'send notification' action? Did you select the 'for each' record as trigger?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi @Kenny_vl
I think the condition should be return an encode query string
the note inside it said:
/**Requires GlideRecord encodedQuery response, example:
**"active=true^short_descriptionSTARTSWITHtest";
*/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Do they also have the email active? User records can be set to not receiving the email.
However: why do you use a GlideRecord query to get the records? Why not simply use conditions (active is true and several fields are not empty and end date is 30 days from now). Those are simple conditions which make it a lot easier to maintain the flow, even after you aren't with the company any more.
For troubleshooting: check the flow execution log. It may show errors.
Also: what are your settings on the 'send notification' action? Did you select the 'for each' record as trigger?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
The condition builder is not an option.
I need to subtract an integer field from the end date and then subtract 30 more days.
The flow execution does not show any errors, see my previous reply to Bhuvan.
Yes, the send notification uses the for each item action as trigger

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
You did, however, point me in the right direction to the issue.
The user's primary email notification device was not active. I've changed it to active and now my flow is working and all notifications are being triggered. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi @Kenny_vl
I think the condition should be return an encode query string
the note inside it said:
/**Requires GlideRecord encodedQuery response, example:
**"active=true^short_descriptionSTARTSWITHtest";
*/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago - last edited 3 hours ago
A for each item flow action expects an array of records.
[EDIT] I stand corrected, further testing showed that my flow action was ignoring the GlideRecord query and returned all records. I modified the script to return an encodedQuery:
var contracts = [];
var grAstContract = new GlideRecord('ast_contract');
grAstContract.addActiveQuery;
grAstContract.addNotNullQuery('contract_administrator');
grAstContract.addNotNullQuery('ends')
grAstContract.addNotNullQuery('u_notice_periodISNOTEMPTY');
grAstContract.query();
while (grAstContract.next()) {
var gdt = new GlideDate(grAstContract.ends);
gdt.addDays((grAstContract.u_notice_period * -1) - 30);
if (gdt.getDate().getValue() == new GlideDate().getValue()) {
contracts.push(grAstContract.sys_id.toString());
}
}
return 'sys_idIN'+contracts.toString();