Copy Forms to Another Issue
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. | Server or Data Center | Any scripting tool, such as JMWE, Power Scripts or Scriptrunner, that uses Groovy. |
Script | import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.bc.issue.properties.IssuePropertyService
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.entity.property.EntityPropertyService
Issue issueOrigin = ComponentAccessor.getIssueManager().getIssueObject("ISSUE-1")
//// When using this script in the script console uncomment the next line:
Issue issueDestination = ComponentAccessor.getIssueManager().getIssueObject("ISSUE-2")
//// When using this script in a transition uncomment the next line:
//Issue issueDestination = issue
ApplicationUser loggedInUser = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
IssuePropertyService issuePropertyService = ComponentAccessor.getComponentOfType(IssuePropertyService.class)
def allProperties = issuePropertyService.getProperties(loggedInUser, issueOrigin.id)
for(def property : allProperties){
if(property.key.contains("proforma.forms")){
EntityPropertyService.SetPropertyValidationResult result =
issuePropertyService.validateSetProperty(
loggedInUser,
issueDestination.id,
new EntityPropertyService.PropertyInput(property.value, property.key))
if(result.isValid()){
issuePropertyService.setProperty(loggedInUser, result)
}
}
} |
Installation instructions |
|
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 |
|