Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,300,435
Community Members
 
Community Events
165
Community Groups

Search in Webhook Response and get a specific value back

Hi,

 

i've got a little problem using smartvalues in my jira automation webhook. 

 

I'm using 

{{webhookResponse.body.additionalInformation.fields.first}}

and receive

{id=33, type=TEXT, values=[21077]}, {id=39, type=TEXT, values=[PG-FBL]}

I'm able to get the values with 

{{webhookResponse.body.additionalInformation.fields.first.values.get(0).jsonEncode}}

{{webhookResponse.body.additionalInformation.fields.first.values.get(1).jsonEncode}}

and receive 

21077

PG-FBL

Now iam creating a new Issue where those values are matched to some customfields.

 

The Problem is, sometimes the foreign system where i get the data from, responds with more then those 2 values and in a different order, so i cant match them right.

 

Is there any possibility to search for the id (id=33 and (id=39) and only get the value back? 

 

Best regards

 

Martin

 

1 answer

0 votes
Filipi Lima Atlassian Team May 17, 2022

Hi, Martin,

One alternative would be to venture into regex matching with the match() function.

See the example from this page:

Let me know if that doesn't make sense but the idea would be to match to different regex using the ID as an anchor.

Filipi Lima Atlassian Team May 17, 2022
{{webhookResponse.body.additionalInformation.fields.first.match("id=33, type=TEXT, values=\[(.*)\]")}}

I can't test it right not, but hopefully that should give you a better idea of what I meant! 

Hi Filipi,

 

it doesnt work. i have a question for testing:

 

{{webhookResponses.get(1).body.additionalInformation.fields.first.match(".*(\d).*")}}

 

This should give ma a digit back, right? This doesnt work as well. The log is empty for your command and in my test as well.  

 

{{webhookResponses.get(1).body.additionalInformation.fields.first}}

returns

 {id=33, type=TEXT, values=[21077]}, {id=39, type=TEXT, values=[PG-OBL]}

 

I even tried this

 

{{webhookResponses.get(1).body.additionalInformation.fields.first.get(0).match(".*(\d).*")}}

log still emtpy. 

 

{{webhookResponses.get(1).body.additionalInformation.fields.first.get(0)}}

returns

 {id=33, type=TEXT, values=[21077]}

 

Maybe you have another idea? Would appreciate it.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
Community showcase
Published in Jira Service Management

Improving the Create Issue Experience in Jira Service Management Cloud

Hello everyone!  We are very excited to announce some much needed changes to the issue create experience in JSM (the blue "create" button) at the top of the screen.  We have just starte...

177 views 7 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you