Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

Tip

You might find Smart Checklist integration with ScripRunner useful for updating checklists using automated scripts. Below you can find the example of adding a checklist to a Jira Issue by means of updating Issue Property with the key com.railsware.SmartChecklist.checklist.

...

Note

⚡️

Panel
panelIconId1c962329-b0c7-474c-9c15-426a686c12f8
panelIcon:logo:
panelIconText:logo:
bgColor#DEEBFF

RequiresChecklists Custom Field"Checklists" Custom Field set up

Panel
bgColor#FFFAE6

☝🏼 NOTE: 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 the "Checklists" Custom Field won't bring the desired result.

Table of Contents

Basic Example

Code

ScriptRunner
Code Block
languagegroovy
def issueKey = 'SAM-8'
def propertyKey = 'com.railsware.SmartChecklist.checklist'
def propertyValue  = '"- 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 result = put('/rest/api/2/issue/' + issueKey + '/properties/' + propertyKey)
        .header('Content-Type', 'application/json')
        .body(propertyValue)
        .asString()
if (result.status == 204) {
    return 'Success'
} else {
    return "${result.status}: ${result.body}"
}

...

📍Use Case: Set Checklist depending on Custom Field Value after Issue Creation

If you want the specific Checklist appended to your newly created ticket depending on the other Custom field value - you can easily do it by adding Script Runner Post Function to your Create Ticket workflow transition.

Panel
bgColor#DEEBFF

You are free to choose any other fields and define your own Custom Value.

...

In this case we will append Checklist Items to the Smart Checklist based on

Status
colourPurple
titleEnvironment
field value 🙌🏻

Assume that you have a custom field named "Environment"

Status
colourPurple
titleEnvironment
with 2 values: Production/Staging. So you expect that while adding a new issue Issue - you'll have a proper checklist assigned.

...

Implementation flow:

  1. Go to

...

  1. Project Settings → Workflows

  2. Choose the Workflow you want to add a post function to and click Edit:

    Image Added
  3. Add a Post Function

3.1. Choose transition and click on the Post Functions link:

...

3.2. Add Post Function:

...

3.3. Choose ScriptRunner Post-Function

...

(Runs a script in a post-function, or a built-in script) and click Add:

...

3.4. Choose

...

Run Script

...

(Run arbitrary code on transition):

...

3.5. Add

...

a Script Code:

...

ScriptRunner

Code Block
languagegroovy
//package com.adaptavist.sr.cloud.samples.events
def issueKey = issue.key
def newSummary = 'Updated by a script'
def cfName = 'Environment'

//get custom field of "seelct" type
def customFields = get('/rest/api/2/field')
        .asObject(List)
        .body
        .findAll { (it as Map).custom } as List<Map>
        
def cfEnvironmentId = customFields.find { it.name == cfName }?.id
def cfEnvironment = issue.fields[cfEnvironmentId]

//get custom field
def environment = cfEnvironment['value'] as String

def propertyKey = 'com.railsware.SmartChecklist.checklist'
def propertyValue

//compare field values
if (environment == 'Production') { 
    propertyValue  = '"- 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"'
}else if (environment == 'Staging') { 
    propertyValue  = '"- Uno\\n+ Dos\\nx Tres\\n~ Quatro\\n"'
}
logger.info('property' + environment)

def result = put('/rest/api/2/issue/' + issueKey + '/properties/' + propertyKey)
        .header('Content-Type', 'application/json')
        .body(propertyValue)
        .asString()
if (result.status == 204) {
    return 'Success'
} else {
    return "${result.status}: ${result.body}"
}

...

Save the script 
Image Removed

...

Publish workflow

Result

The needed checklist is created.

...


3.6. Check added post function and Publish Draft:

...

You're done! Now every time the Issue will be transitioned to

Status
colourBlue
titleto do
, based on the
Status
colourPurple
titleEnvironment
field value the proper Checklist items will be added to your Smart Checklist🎉

...

Info

For any questions or feature requests contact us: smartchecklist@railsware.com