Copy Forms to Another Issue.

Purpose

Hosting

Compatible Tools

Purpose

Hosting

Compatible Tools

Copy forms from one issue to another. The forms will be copied with all entered values and will be in the same state (open, submitted, locked) on the destination form as they were on the source form.

Cloud

Any scripting tool, such as JMWE, Power Scripts or Scriptrunner, that uses Groovy.

Script

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 def issueKeyOrigin = 'ISSUE-1' //// When using this script in the script console uncomment the next line: def issueKeyDestination = 'ISSUE-2' //// When using this script in a transition uncomment the next line: //def issueKeyDestination = issue.key def proformaPropertyKeys = [] def allIssueProperties = get('/rest/api/3/issue/' + issueKeyOrigin + '/properties/') .header('Content-Type', 'application/json') .asObject(Map) if (allIssueProperties.status == 200){ for(def property : allIssueProperties.body.keys){ if(property.key.contains("proforma")){ proformaPropertyKeys.add(property.key) } } } def issueDestinationProperties = get('/rest/api/3/issue/' + issueKeyDestination + '/properties/') .header('Content-Type', 'application/json') .asObject(Map) if(!issueDestinationProperties.body.keys.toString().contains("proforma.forms.i")){ if(!proformaPropertyKeys.isEmpty()){ for(def key : proformaPropertyKeys){ def property = get('/rest/api/3/issue/' + issueKeyOrigin + '/properties/' + key) .header('Content-Type', 'application/json') .asObject(Map) if(property.status == 200){ def result = put('/rest/api/3/issue/' + issueKeyDestination + '/properties/' + property.body.key) .header('Content-Type', 'application/json') .body(property.body.value) .asString() } } } }

Installation instructions

  • If used in a transition:

    • Change the issue key in line 1 to the key of the issue you want to copy the forms from.

    • Comment line 3 and uncomment line 5.

  • If used in the script console:

    • Change the issue key in line 1 to the key of the issue you want to copy the forms from.

    • Change the issue key in line 3 to the key of the issue you want to copy the forms to.

Possible use cases

This script copies all of the forms, including values which have been entered in form fields, from one issue to another. All related form information such as the current status (open/submitted/locked), format and conditions will be maintained.

This script can be useful for passing information when creating related issues, or child issues. It can also be used in a regular transitions to pass information between teams who are working on a coordinated effort (such as HR, Facilities and IT teams working to onboard new employees).

Limitations

  • Script will only run if destination issue has no ProForma forms. Alternatively, you can comment out lines 24 and 39 to override any existing issues on the destination form.

  • User performing the action needs to have access to both issues.