Add Smart Checklist Templates using the Template ID to your issues via different tools available in Jira - ScripRunner for Jira, Automation for Jira, JMWE.
Contents ππΌ
βπΌ NOTE: For issues with multiple checklist tabs, all Public API calls will only interact with the Default Checklist tab, and any templates will be imported into that tab.
Steps on how to apply the Smart Checklist Template via Automation for Jira
π‘HINT: This is just an example of a use case with Issue created trigger. You can select any other available trigger based on your needs.
Create a personal access token
Navigate to User icon β Profile β Personal Access Tokens β Create Token
Copy token value
Go to Project Settings β Project Automation β click Create rule: (or go to Administration β System β Automation rules β click Create rule: )
Create a trigger
Choose Issue created
Save
Add component - New action
Choose Send web request as the first action.
Fill in the fields with the following values:
Webhook URL | http://Jira_base_URL/rest/railsware/1.0/checklist?issueKey={{issue.key}} |
---|---|
Headers | Header Name: Example: |
HTTP method | GET |
Webhook body | Empty |
Wait for Response | Check this option |
c. Save
Add component - New action
Choose Send web request as the second action
Fill in the fields with the following values:
Webhook URL | http://Jira_base_URL/rest/railsware/1.0/checklist/{{webhookResponse.body.checklists.get(0).checklistId}}/template/${templateId} Where |
---|---|
Headers | |
Authorization | Bearer + token (mentioned in step 1) |
HTTP method | POST |
Webhook body | Empty |
Wait for Response | Donβt check this option |
βπΌNOTE: You can find the Template ID by going to Issue β Smart Checklist β 3 dots menu β Manage Templates β Expand the Template you are looking for β Copy the Template ID β
Or going to Jira Administration β Manage apps β Smart Checklist Settings β Templates tab β Find needed template β Click on the Template you are looking for β Copy the Template ID β
Check out more about Templates IDs here βhttps://railsware.atlassian.net/wiki/spaces/CHKSDC/pages/edit-v2/4085284902?draftShareId=60155a82-23ad-49b1-8075-4f1126d53d8b
c. Save
Name your new Automation and Turn it on
You're done! Now every time an issue is created, the proper template will be added to your Smart Checklist π
Steps on how to apply the Smart Checklist template via ScriptRunner
Go to Jira Administration β ScriptRunner β Console
Add the following script:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.sal.api.UrlMode import com.atlassian.sal.api.net.Request import com.atlassian.sal.api.net.TrustedRequestFactory import groovy.json.JsonSlurper import groovyx.net.http.URIBuilder def testIssueKey = "TEST-1" def templateId = 10 class SmartChecklistAPI { def trustedRequestFactory = ComponentAccessor.getOSGiComponentInstanceOfType(TrustedRequestFactory.class) def applicationProperties = ComponentAccessor.getApplicationProperties() long getChecklistId(String issueKey) { def url = applicationProperties.getString("jira.baseurl") + '/rest/railsware/1.0/checklist?issueKey=' + issueKey def checklistResponse = sendGetRequest(url) assert checklistResponse instanceof Map assert checklistResponse.checklists instanceof List assert checklistResponse.checklists.get(0) instanceof Map return (long) checklistResponse.checklists.get(0).get("checklistId") } void applyTemplate(Long checklistId, Long templateId) { def url = applicationProperties.getString("jira.baseurl") + '/rest/railsware/1.0/checklist/' + checklistId + '/template/' + templateId sendPostRequest(url) } private Object sendGetRequest(String url) { def request = trustedRequestFactory.createTrustedRequest(Request.MethodType.GET, url) def host = new URIBuilder(url).host request.addTrustedTokenAuthentication(host) def responseBody = request.execute() return new JsonSlurper().parseText(responseBody) } private void sendPostRequest(String url) { def request = trustedRequestFactory.createTrustedRequest(Request.MethodType.POST, url) def host = new URIBuilder(url).host request.addTrustedTokenAuthentication(host) request.execute() } } def checklistAPI = new SmartChecklistAPI() def checklistId = checklistAPI.getChecklistId(testIssueKey) checklistAPI.applyTemplate(checklistId, templateId)
Where testIssueKey
and templateId
should be changed accordingly.
Click Run
π‘HINT: This is just an example of a use case using Console. You can also use this script in other ScriptRunner places, like Workflows etc. In such a case replace value of testIssueKey
with issue.key
to get a reference of the current issue.
Steps on how to apply the Smart Checklist template via JMWE
Navigate to Jira Administration β Manage apps β Jira Misc Workflow Extensions Settings β Select Groovy console
Add the following script:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.sal.api.UrlMode import com.atlassian.sal.api.net.Request import com.atlassian.sal.api.net.TrustedRequestFactory import groovy.json.JsonSlurper import groovyx.net.http.URIBuilder def testIssueKey = "TEST-1" def templateId = 10 class SmartChecklistAPI { def trustedRequestFactory = ComponentAccessor.getOSGiComponentInstanceOfType(TrustedRequestFactory.class) def applicationProperties = ComponentAccessor.getApplicationProperties() long getChecklistId(String issueKey) { def url = applicationProperties.getString("jira.baseurl") + '/rest/railsware/1.0/checklist?issueKey=' + issueKey def checklistResponse = sendGetRequest(url) assert checklistResponse instanceof Map assert checklistResponse.checklists instanceof List assert checklistResponse.checklists.get(0) instanceof Map return (long) checklistResponse.checklists.get(0).get("checklistId") } void applyTemplate(Long checklistId, Long templateId) { def url = applicationProperties.getString("jira.baseurl") + '/rest/railsware/1.0/checklist/' + checklistId + '/template/' + templateId sendPostRequest(url) } private Object sendGetRequest(String url) { def request = trustedRequestFactory.createTrustedRequest(Request.MethodType.GET, url) def host = new URIBuilder(url).host request.addTrustedTokenAuthentication(host) def responseBody = request.execute() return new JsonSlurper().parseText(responseBody) } private void sendPostRequest(String url) { def request = trustedRequestFactory.createTrustedRequest(Request.MethodType.POST, url) def host = new URIBuilder(url).host request.addTrustedTokenAuthentication(host) request.execute() } } def checklistAPI = new SmartChecklistAPI() def checklistId = checklistAPI.getChecklistId(testIssueKey) checklistAPI.applyTemplate(checklistId, templateId)
Where testIssueKey
and templateId
should be changed accordingly.
Click the
Test Groovy script
buttonEnter Issue Key where you want to apply template β Click Test
You will see a message π
π‘HINT: This is just an example of a use case using Groovy Console. You can also use this script in other JMWE places, like JMWE Workflow extentions etc. In such a case replace value of testIssueKey
with issue.key
to get a reference of the current issue.
π« Don’t hesitate to get in touch with us for any questions or feature requests!