Purpose | Hosting | Compatible Tools |
---|---|---|
Unlock a form which has been set to Lock when submitted | 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.onresolve.scriptrunner.runner.customisers.PluginModule import com.onresolve.scriptrunner.runner.customisers.WithPlugin import com.thinktilt.proforma.api.ApiUser import com.thinktilt.proforma.api.FormApi @WithPlugin("com.thinktilt.proforma.add-on") @PluginModule ApiUser apiUser @WithPlugin("com.thinktilt.proforma.add-on") @PluginModule FormApi formApi ////If used in a transition, comment next line: Issue issue = ComponentAccessor.getIssueManager().getIssueObject("ISSUE-1") String formName = "Form Name" ApplicationUser loggedInUser = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser() IssuePropertyService issuePropertyService = ComponentAccessor.getComponentOfType(IssuePropertyService.class) Closure<Long> getFormId = { def property, String name -> def slurper = new groovy.json.JsonSlurper() def parsedJson = slurper.parseText(property.value) String id parsedJson.forms.each(){ form -> if(form.name.equals(name) && form.lock){ id = form.id.toString() return } } if(id){ return Long.valueOf(id) } } def allProperties = issuePropertyService.getProperties(loggedInUser, issue.id) for(def property : allProperties){ if(property.key.equals("proforma.forms")){ Long unlockFormId = getFormId(property, formName) if(unlockFormId){ def form = formApi.unlockForm(apiUser.getCurrentUser(), issue.key, unlockFormId) } } } |
Installation instructions |
|
Possible use cases | Use this script to unlock a form when it reaches a given status, for example if an Approver needs to add or amend information on the form. |
Limitations |
|