...
Result
...
Implementation flow:
Go To Workflow Editor
Choose "Script Post Function" Script Runner
Choose "Custom Script Post Function"
Add inline Script
Variables checklistProd and checklistStage are used for keeping the proper value of the checklist (in text format)
ScriptRunner
Code Block language groovy import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.ModifiedValue import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import org.apache.log4j.Level log.setLevel(Level.DEBUG) //Grab necessary Components def cfm = ComponentAccessor.getCustomFieldManager() def optionsManager = ComponentAccessor.getOptionsManager() def cfEnv = cfm.getCustomFieldObjectByName("Environment") def cfEnvtValue = issue.getCustomFieldValue(cfEnv) def cfEnvValueString = cfEnvtValue.toString() def changeHolder = new DefaultIssueChangeHolder() def checklistProd = "- ToDo List\n+ Checked\nx Skipped\n~ In Progress\n# Another ToDo List\n- Unchecked\n> Quote line 1 https://rw.rw\\n> Quote line 2\n> Quote line 3\n" def checklistStage = "- Uno\n+ Dos\nx Tres\n~ Quatro\n" log.info("checklistProd: " + checklistProd) log.info("checklistStage: " + checklistStage) log.info("Environment"+ cfEnvValueString) if (cfEnvValueString == "Production") { //Set custom text field def cfClient = cfm.getCustomFieldObjectByName("Checklists") issue.setCustomFieldValue(cfClient,checklistProd) } else if (cfEnvValueString == "Staging") { //Set custom text field def cfClient = cfm.getCustomFieldObjectByName("Checklists") issue.setCustomFieldValue(cfClient,checklistStage) }
Save the script. IMPORTANT! Make the Post Function is placed as a #1 Step!
Customize checklist visibility by user group/ user role/ ticket type
...
Code Block |
---|
import com.atlassian.jira.ComponentManager import com.atlassian.jira.security.roles.ProjectRoleManager import com.atlassian.jira.component.ComponentAccessor ProjectRoleManager projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager.class); def usersRoles = projectRoleManager.getProjectRoles(ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(), issue.getProjectObject())*.name; return usersRoles.contains("Administrators") |
Info |
Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|