Extract questions and answers from a form in automation
Asked by Anthony Roldan:

Hello,

I built a form and now want to extract the questions and answers into the description field in automation. Why not just open the form? It's because the form is very long, and we want to create sub-tasks that rely on certain questions and answers to be completed. So that entails cutting out any irrelevant information so that the task can be completed without searching the entire form.

Any way to dynamically show these questions and answers, or is my only option to manually type out these questions and use their respective custom fields?

Thanks in advance!


Answers:
author: Darryl Lee
body: Apparently forms data is stored in issue properties, so the data should be accessible that way. Here's a good Q\&A about the topic:

* [How to access the form data in Jira Automations](https://community.atlassian.com/t5/Jira-Service-Management/How-to-access-the-form-data-in-Jira-Automations/qaq-p/2050277)

As [@Simon Herd](/t5/user/viewprofilepage/user-id/4352233) recommended, you probably definitely want to install [**Entity Property Tool for Jira**](https://marketplace.atlassian.com/apps/1214509/entity-property-tool-for-jira?hosting=cloud&tab=overview) (temporarily, because I believe it still has the bug where the "Personally enabled" config tool still does not work, and once you enable it, everyone can see it, which can be... confusing and possibly dangerous.)

comments: author: Anthony Roldan
body: So this mainly works for getting the answers/custom fields from a form, but unfortunately the questions to those answers are something that isn't stored in

\<yourinstanceurl\>/rest/api/2/issue/\<yourkey\>/properties?expand=names

It would be nice to have the questions from a form be as dynamic as the custom fields, but unfortunately after looking through many old forum posts it doesn't look like there's any real solution other than typing out my form questions one by one.


author: Darryl Lee
body: I found the questions. They can be found in an undocumented endpoint:
> https://**YOURSITE** .atlassian.net/gateway/api/proforma/cloudid/**YOURCLOUDID** /api/3/issue/**{{issue.id}}** /form/**FORMNUMBER**

So, YOURSITE you know. You can find YOURCLOUDID by looking at the URL for your Atlassian Admin interface: <https://admin.atlassian.com/o/YOURCLOUDID/overview>

Weirdly my cloudid for proforma matches the ID for Statuspage or Atlas as shown in my Overview, so you might need to try that.

<https://manage.statuspage.io/cloud/MYCLOUDID>  
<https://team.atlassian.com?cloudId=MYCLOUDID>

OH! and {{issue.id}} != issue key, but rather a numerical value for your Jira issue (sequential?) Thankfully there's an undocumented Smart Value you can use {{issue.id}}

FORMNUMBER can be found when you are editing a form, in the URL:

<https://YOURSITE.atlassian.net/jira/software/c/projects/YOURPROJECT/settings/forms/form/FORMNUMBER/edit>

But anyways, this endpoint ends up giving us a JSON file which includes a **questions** section! Unfortunately this call is very slow - it took about 5 seconds when I called it from Automation.

Anyways though, that endpoint includes this section:

```
"questions": {
  "1": {
    "type": "ts",
    "label": "Name",
    "validation": {}
  },
  "2": {
    "type": "ts",
    "label": "Phone",
    "validation": {}
  },
  "3": {
    "type": "ts",
    "label": "Department",
    "validation": {}
...
}
```

Which is... weird. It's not an array, but each question is individually numbered, so if you want to get the question's labels you have to do:

{{webResponse.body.design.questions.1.label}}  
{{webResponse.body.design.questions.2.label}}  

I can't think of an elegant way to loop through all the questions. These all failed:

{{webResponse.body.design.questions.label}}  
{{#webResponse.body.design.questions}}{{label}}{{/}}  
{{#webResponse.body.design.questions}}{{.}}{{label}}{{/}}

ANYWAYS, the comments in [JSCLOUD-10671](https://jira.atlassian.com/browse/JSDCLOUD-10671?focusedId=3172703&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-3172703) include some other endpoints and lots of grousing about how this really needs to not suck so much (AGREED).

++**Export form data as XLS:**++

https://${JIRA_CLOUD_SUBDOMAIN}.atlassian.net/gateway/api/proforma/cloudid/${CLOUD_ID}/api/1/issues/${ISSUE_ID}/forms/1/spreadsheet

++**Add a form to a ticket:**++

https://\<site\>.atlassian.net/gateway/api/proforma/cloudid/\<cloudid\>/api/2/issues/{{issue.id.urlEncode}}/forms