How do I use scripts in the conditions of Look Up Record in Flow Designer?

Andr_12
Kilo Contributor

I'm trying to make a script but I'm having a hard time. I need to handle the subject of an email that will be received by the Inbound Email trigger, and for this I need to make a script on the conditions part of the Look Up Record action. I believe that GlideRecord should be used, but I would like an example so that I can follow better.

1 ACCEPTED SOLUTION

I'm not clear on the question, I think.

Does the example script return the code you're looking for and you are just having a hard time getting the condition to work and select only the appropriate records?  if that's the case, I think all you need to do is concatenate that string and return an encoded query instead of the result string in your example, so instead of:

var result = str.match(r);

try:

var result ="descriptionLIKE" +str.match(r);

 

 

then you can return the encoded query with your return result; line

 

View solution in original post

3 REPLIES 3

Brian Bouchard
Mega Sage

The email subject can be accessed using email.subject

 

For example, if you need a condition based on the "UPDATE" being in the subject, you could write the condition like: 

email.subject.indexOf("UPDATE") > -1

 

If you don't care about case, you would do:

email.subject.toLowerCase().indexOf("update") > -1

 

More info available on Inbound Actions here:
https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/notification/task/t_C...

 

Accessing email Object variables:

https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/notification/referenc...

Within the subject of the email comes a code (Example: "Case Created | CS1234567: Problem description"), and I need to filter that code ("CS1234567") to search within the incidents created (that has this code in the description). I can't put this filter under conditions. Following images:

 

Here is where I need to place the script:

find_real_file.png

 

Here is an example of the treatment I need to do on the subject:

find_real_file.png

 

I need to do this treatment inside the conditions script, so I can find the right record.

I'm not clear on the question, I think.

Does the example script return the code you're looking for and you are just having a hard time getting the condition to work and select only the appropriate records?  if that's the case, I think all you need to do is concatenate that string and return an encoded query instead of the result string in your example, so instead of:

var result = str.match(r);

try:

var result ="descriptionLIKE" +str.match(r);

 

 

then you can return the encoded query with your return result; line