The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Need help with a query for Flow Designer Action that's not working

Community Alums
Not applicable

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.
find_real_file.png

Here is the Action in Flow Designer (this is returning false for the same sys_id(also the element ID which is the same)

find_real_file.png

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.

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Hi

the correct code has to be

gr.addQuery('element_id', inputs.sysid);

 

Kind regards
Maik

View solution in original post

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Hi

the correct code has to be

gr.addQuery('element_id', inputs.sysid);

 

Kind regards
Maik

Community Alums
Not applicable

Thank you, Maik, that solved the issue.  Much appreciated