Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to format Variable in smart value creation string

spudsrus November 17, 2024

I'm creating an automation trying to link up some info with an external api. (BambooHR)
To do that, I need to get an ID off this API to later on make requests against.

I'm able to query a report which is a list of emails and IDs that match with them.
Trying to search the report is where I'm getting stuck.
If I manually specify a valid email in the query it works.

{{#webResponse.body.employees}}{{#if(workEmail.length())}}{{#if(equals(workEmail.toLowerCase(),"email@domain.com"))}}{{id}}{{/}}{{/}}{{/webResponse.body.employees}}

I can't figure out if/how it's possible to put in the value of issue.reporter.emailAddress.toLowerCase() where the "email@domain.com" is in the query.

Either end up with errors about parameter mismatches and needing to close braces and other statements or blank searches.
I also tried creating a separate smart variable to reference it but have the same issue where I can't seem to format it correctly.

Automation rule Difficulty.png

Any tips on getting the variable in there?



For reference the webresponse I'm trying to get id values out of looks like this:
workemail example.png
I have the value of the workEmail property, trying to get the associated id.

2 answers

1 accepted

0 votes
Answer accepted
spudsrus November 19, 2024

Found this amazing article by @Bill Sheboy which was the fix.

Painful to not have a way to use variables within the list iteration.
Bill, sorry to randomly tag you on this, but you've written by far the best article / workaround post I've seen for this issue and I really appreciate your work.

I've updated my method to use regex over the delimited string and it seems to be working.

0 votes
Vijay Dadi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 18, 2024

Hello,

 

use the jsonEncode function to capture any values in rest response which has special chars like @.

 

for example: emailAddress.jsonEncode.

 

Hope this helps !

Vijay

spudsrus November 18, 2024

Can't find any anything in doco about using jsonEncode to pull values out of a json string.
Are you able to provide an example?

Updated my question to include sample json data that I'm trying to search.

Like Susan Waldrip likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events