Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Flow Designer Look up Record with Scripted Condition

JamesLindsay
Giga Guru

Hi, I am changing out an Inbound Email Action for a Flow created in designer. The Inbound Email action creates an incident record for job failures executed by our Job Scheduling software. I have a custom CMDB table where Job CIs are maintained. Since the same Job Name can run on different servers, a job CI name is uniquely identified by it's display_value (jobName@thisServer). In the inbound email action, I take two values from the email body, jobname and server, and use those values to do a glide record query passing the return value into the incident as the cmdb_ci (Configuration Item)

 

var server = email.body.server;
server = server.substr(0, server.indexOf("_"));
var jobname = email.body.jobname;
jobname = jobname.trim();
var dn = jobname + "@" + server;
var theJob = new GlideRecord('cmdb_ci_batch_job');
theJob.addQuery('u_display_name', dn);
theJob.query();
while (theJob.next()) {
current.cmdb_ci.setDisplayValue(theJob.name);
}

 

In the flow I am trying to use the lookup record

JamesLindsay_0-1675279309619.png

My thought was I could use a script to satisy the Display Name Is condition
var server = fd_data.trigger.body_text.server;
server = server.substr(0, server.indexOf("_"));
var jobname = fd_data.trigger.body_text.jobname;
jobname = jobname.trim();
var dName = jobname + "@" + server;
return dName

 

But using the script button seems to remove the condition itself. That is when I add that little script, save the flow and then reopen that step, the "Display Name is" portion is gone or empty. Testing shows nothing was passed. Am I using the Script capability wrong??

1 ACCEPTED SOLUTION

JamesLindsay
Giga Guru

I fixed this by realizing that I had to return an encoded query.

View solution in original post

3 REPLIES 3

JamesLindsay
Giga Guru

I fixed this by realizing that I had to return an encoded query.

amu
Tera Contributor

Can please post the exact query you have use, I am trying to implement a similar kind of solution , however it is not working for me as I need pass a variable in the encoded query.

Piotr P
Tera Contributor

Hi,

Did you achieve this by adding scripted condition on your flow only, if so whats your final script?