automation : How iterate on API REST Forms format/answers

Mélanie Liguet
Contributor
August 8, 2024

Hi, 

I need to retrieve some form fields in JSM request description

For this, I created an automation, which uses the  API REST Forms

format/answers returns me the answers entered by the customer.

 

This works, but I can't create a loop on the number of responses, which forces me to hard-code multiple GET()

 

Capture.PNG

this is not very clean. Can you explain to me how to iterate on the results?

 

regards, 

3 answers

0 votes
Patricia Francezi
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 28, 2024

Hello @Bruno Altenhofen - could you help on this one?
I have the same question for a little different approach 

I want to use the answer to create Asset Objects. Can we filter the fields by their fiedkey? 

I know this is should be a different question, but this could be an Article inspirantion for you. Thanks for your articles so far :) 

Bruno Altenhofen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 2, 2024

Hey @Patricia Francezi 

Sure! :D

Unfortunately, we are limited here by the automation rule editor’s capabilities, which do not natively support loops or dynamic iteration over collections, such as arrays of responses. While we can sometimes use smart values and conditional logic to address this issue by verifying if a response exists before accessing it, this approach might not be suitable for scenarios where we need to retrieve responses separately. I've personally attempted various complex workarounds, including using regex with smart values, but I still receive a largely blank response from my web request... ç.ç

Therefore, it might be best for you and @Mélanie Liguet to manipulate the field values individually by utilizing the Forms properties.

I'll share a screen recording demonstrating how I use form responses to create an object in Assets:


Additionally, please be aware that Forms properties will be deprecated once the new Forms Smart-values are rolled out. Probably, with the introduction of Forms Smart-values, handling form values will likely become more efficient and streamlined for us... :B

Like Bill Sheboy likes this
0 votes
Marc - Devoteam
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.
August 9, 2024

Hi @Mélanie Liguet 

What information is logged in the variable, are this multiple options?

If they are do an advanced branch in the rule based on the variable, then send the web request and edit action in the branch.

0 votes
Bill Sheboy
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.
August 8, 2024

Hi @Mélanie Liguet 

First thing, I am not currently using JSM and so my suggestions are based on what I know about automation rules, in general.  With that out of the way...

 

You seem to be using this endpoint for getting the answers in the simplified format: https://developer.atlassian.com/cloud/forms/rest/api-group-forms-on-issue/#api-issue-issueidorkey-form-formid-format-answers-get

That one seems to indicate looping over the body, but you show what appears to be lists of labels and answers separated within the body.

Is that what you see if you write the entire {{webhookResponse.body}} to the audit log?

Next, what are you trying to do with the information as you iterate over it?

 

Kind regards,
Bill

Mélanie Liguet
Contributor
August 9, 2024

Hi, 

 

Yes i use this apir rest.I I call it to have only the customers' responses rather than the entire form.
I retrieve the question webhookResponse.body.label and the response webhookResponse.body.answer.

The goal is to allow the support team to be more responsive by directly displaying the information they need

 

the api does not allow to have the number of results returned

 

I don't use {{webhookResponse.body}} because it is not formatted and therefore not very readable and I have useless information for the team such as the id or the choice

 

regards

Bill Sheboy
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.
August 9, 2024

If you try writing {{webhookResponse.body}} to the audit log when the rule runs, it may indicate how to iterate over the values, producing something more useful for the team.

Bill Sheboy
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.
August 21, 2024

Hi @Mélanie Liguet 

I wanted to follow-up to learn if you had tried other parsing options yet.  Perhaps something like this:

{{#webhookResponse.body}}
* label: {{label}} with an answer: {{answer}}
{{/}}

 

Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events