Work has already started on the new Forms API functionality and we now have some experimental APIs available for use. So now Marketplace Partners can already integrate forms into their products.
For more information, please refer to the features below:
As an extra option of workaround to the feature request "Forms Automation: Access form fields with smart values (smartvalues)", this article is meant to help users who want to access the form field and update them with other values automatically, as well as manage with more than one form in a ticket. This can be achieved using the new experimental feature of Forms API to save form answers to different forms.
Create an Automation rule:
Getting all forms on an issue:
- The web method will be a Get:
Get /jira/forms/cloud/{cloudId}/issue//issue/{issueIdOrKey}/form
- The cloudId will be your Cloud ID and not your Org ID. The easy way to get the cloud id is to go to https://<instance>.atlassian.net/admin/jira-service-desk/portal-only-customers. You will get the Cloud id in the URL (e.g.: https://admin.atlassian.com/s/<cloud_id>/jira-service-desk/portal-only-customers)
- The issue ID or issue Key that you are using. To add the issueId or issueKey dynamically, you can use the smart value {{issue.id}} or {{issue.key}}
- Using the log action with the smart value below to get the web response body and the reference IDs of which form:
{{webResponse.body}} - get the body
{{webResponse.body.id}} - get the ids
{{webResponse.body.id.get(0)}} - get the first id
{{webResponse.body.id.get(1)}} - get the second id
{{webResponse.body.id.get(2)}} - get the third id
Get /jira/forms/cloud/{cloudId}/issue/{issueIdOrKey}/form/{formId}
- The formId will be in the id of the form and not the formTemplate id (for more information about it, please check this article). And, in order to dynamically get the first form it will be necessary to use the smart value {{webResponse.body.id.get(0)}} instead of the {formId}:
Get /jira/forms/cloud/{cloudId}/issue/{issueIdOrKey}/form/{{webResponse.body.id.get(0)}}
Put /jira/forms/cloud/{cloudId}/issue/{issueIdOrKey}/form/{formId}
- To get the first form it will be necessary to use the smart value {{webResponse.body.id}} instead of {formId}:
Put /jira/forms/cloud/{cloudId}/issue/{issueIdOrKey}/form/{{webResponse.body.id}}
add
, remove
and set
.{
"answers": {
"1": {
"text": "field update by automation/API 1"
},
"2": {
"choices": ["2"]
}
}
}
For more information about how access the form structure to get a field ID, please refer to the article "Reading a Forms(ProForma) field value without the JSON tab"
Note: To call experimental methods the "
X-ExperimentalApi" and "opt-in"
header must be provided on the web request headers.
This workaround will work as shown in the screen recording below:
Bruno Altenhofen
Atlassian Engineer - The guy from Proforma(Jira Forms)
e-Core
Krakow - Poland
4 comments