Copy a Form to the same project and for different projects using Automation and API

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: In ProForma for Jira Cloud, allow copying forms between Issues with Automation", this article is meant to help users who want to use the new experimental features of the Forms API to automatically copy a form between tickets.

 

Workaround steps:

  • Create an Automation rule:
    • First, it will be needed to create an API token for the Web Request process. The Web Request needs your credentials and an API token encoded with base64.  For more information about this procedure, please refer to the documentation below:
      -    - Automation for Jira - Send web request using Jira REST API

    • We need to use the new API functionality of "Copy forms" in a Post web request. For example:
      • Copy a form on an issue status transition to a linked issue:

        - The web method will be a POST:

        POST https://api.atlassian.com/jira/jira/forms/cloud/{cloudId}/issue/{sourceIssueIdOrKey}/form/copy/{targetIssueIdOrKey}

        - 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}}

        - The formId will be in the universally unique identifier "uuid" format. To get it you can use the Forms properties structure below:

        https://<yourCloudURL>.atlassian.net/rest/api/2/issue/<issueId>/properties/proforma.forms

        Screenshot 2023-05-22 at 17.48.05.png

        - To add the formId dynamically, you can use the smart value below:

        {{issue.properties."proforma.forms".forms.uuid}}

        - The targetIssueIdOrKey will be the issue that you want to copy. The icing on the cake here is to use the smart value below to get the ID of the linked issue:

        {{issue.issuelinks.inwardIssue.key}}

        - The automation rule will be as shown in the screenshot below:

        Screenshot 2023-06-09 at 19.00.27.png

 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:

 For different projects, the workaround will be the same, but with just a few more details:

  1. The automation rule must be with a global scope containing the projects that will communicate (where the forms will be copied and sent), in this example, I use two projects:
    Screenshot 2023-09-29 at 13.45.32.png
  2. It will be necessary to add a way to filter the linked issue containing the form that you want to copy, this will depend on each use case, in this example, I used "issues blocked by".

This workaround will work as shown in the screen recording below:

10 comments

Ralph Gerald Varon August 16, 2023

Is there a smart value

{{issue.properties."proforma.forms".forms.uuid}}

if multiple forms are attached, it will return multiple uuid as well. how can we get the UUID of a specific attached form? 

Like Bruno Altenhofen likes this
Mogens Hald Kristensen August 29, 2023

The target issue id  smartvalue should be {{issue.issuelinks.outwardIssue}}

Like Bruno Altenhofen likes this
Bruno Altenhofen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 20, 2023

Hello @Ralph Gerald Varon

Allow me to share with you this article that explains how to manipulate multiple forms separately:

Thanks!

Mauricio Heberle
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.
September 26, 2023

It works for multiple projects, Ive just tested here. Thanks!

Like Bruno Altenhofen likes this
Bruno Altenhofen
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 29, 2023

Hi @Mauricio Heberle

Thanks for the feedback!

Yes!!! I've updated this info in the article!! :D

Cheers!!

Like Mauricio Heberle likes this
Mauricio Heberle
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.
September 29, 2023

@Bruno Altenhofen You're welcome! If this could be added to the component "Add Form", would be great. Also, I noticed that for some automations, it is necessary to refetch issue data before sending the web request. 

Jimmy Karlsson December 21, 2023

Hi,

Is there any way to copy all of the forms from one issue to another? I´m getting this to work the way you have set it up, and when I have several forms the smart value {{issue.properties."proforma.forms".forms.uuid}} returns all the id's as this;

5b44c132-802b-48b0-a5cb-60b864360d37, 226dac84-d5d5-4355-8080-1f4cc550148c, 2d4b93e8-112a-4faf-98f8-abe9c11ee329

This does not work in the "Custom data" field tho, I´m getting this error:

{"errors":[{"status":400,"code":"BAD_REQUEST","title":"There was an issue with your request","detail":"1 error found in JSON: (1) /ids(0) should be a UUID"}]}

Nia Yanes Barreto
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 29, 2024

Would this solution only work with ProForma forms? If so, is there a workaround for Jira built-in forms?

Mauricio Heberle
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.
March 29, 2024

@Nia Yanes Barreto Its for forms created in "Forms" module within Jira Service Management projects.

Lukasz April 12, 2024

Hello @Bruno Altenhofen 

Is it possible to use this workaround to copy a form from one project to another project when both of them are Team-managed (next-gen) projects? In that case, are there any special steps to follow?

Thanks for your response!

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events