
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 05:42 AM
I have the following script that I'm using for a Flow Action. I include the Background Script (with black screen) and the Script for the action, and the Results of the encoded query directly on the sys_journal_field table. In Scripts background, it runs fine and returns true as it should. When I modify it slightly to get the inputs and outputs in the action, it returns false. I can't see why this is flipping in the action.
The logic: I just need to see if there was a post starting with RE: in the last 48 hours don't care how many.
Background script (working as it should)
var gr = new GlideRecord('sys_journal_field');
gr.addQuery('element_id', 'fe02860e87550d10cf30fe6acebb3512');
gr.addEncodedQuery('element=comments^valueSTARTSWITHRE:^sys_created_onRELATIVEGT@hour@ago@48');
gr.query();
if (gr.getRowCount() >= 1) {
gs.log('True');
} else {
gs.log('False');
}
The results of this are True
Here are the Servicenow Encoded Query results in the interface.
Here is the Action in Flow Designer (this is returning false for the same sys_id(also the element ID which is the same)
as you can see, the sys_id's are the same, and the backgrounds script runs as it should, but the action reverses the results. Can anyone see what is incorrect (if anything)?
Much appreciated.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 05:54 AM
Hi
the correct code has to be
gr.addQuery('element_id', inputs.sysid);
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 05:54 AM
Hi
the correct code has to be
gr.addQuery('element_id', inputs.sysid);
Kind regards
Maik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2022 05:59 AM
Thank you, Maik, that solved the issue. Much appreciated