Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

You might find Smart Checklist integration with ScripRunner useful for updating checklists using automated scripts. 

Since we use Issue Properties as primary memory storage for checklists, it's required to update Issue Property to have checklists updated with any type of automation. Updating "Checklists" Custom Field won't bring the desired result. We are in touch with ScriptRunner support to identify if it's possible to do via scripting in the current implementation.


Basic Case

However, if the issue has no checklist set yet - it's possible to initiate initial rendering by pushing value to the custom field.

  1. Setup "Checklists" custom field. Check instructions here "Checklists" Custom Field
  2.  
ScriptRunner
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()

def issue = issueManager.getIssueObject("PROJ-7")
def changeHolder = new DefaultIssueChangeHolder()
def String myval = "- 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"

// a text field
def textCf = customFieldManager.getCustomFieldObjectByName("Checklists")
textCf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(textCf), myval),changeHolder)

Result


Update/append checklist with post function during a workflow status change.

This could be achieved by updating Issue Property with the key com.railsware.SmartChecklist.checklist using REST API Endpoints https://scriptrunner.adaptavist.com/5.6.8/jira/rest-endpoints.html



Set Checklist depending on Custom Field Value after Issue Creation

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




Error rendering macro 'excerpt-include' : No link could be created for 'Support'.


  • No labels