Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to call Jira macro evaluation (for Simple TaskLists automation)

Yves Martin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2020

 Hello

I am looking for a way to instantiate a Simple TaskLists template at issue creation, and I start with a Script Runner issue listener on create event

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue

MutableIssue mutableIssue = (MutableIssue)issue;
mutableIssue.setDescription((issue.description ?: "") + "\n{tasklist}Validation{tasklist}");

IssueManager issueManager = ComponentAccessor.getIssueManager()
issueManager.updateIssue(event.user, mutableIssue, com.atlassian.jira.event.type.EventDispatchOption.DO_NOT_DISPATCH, false);

But it does not produce expected effect: "tasklist" macro is not evaluated and replaced by a list of "task:id=xxx" macros in description.

I guess this evaluation and replacement only happens in web editor.

So is there a way to programmatically call "tasklist" macro evaluation, so that my listener can generate tasks list from template?

1 answer

1 accepted

1 vote
Answer accepted
Anthony De Moss
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2020

hi @Yves Martin - our plugin evaluates the macros whenever an issue_event is fired. More often than not, when inserting a {task} macro, or {tasklist} macro and it doesn't get evaluated, it is because an issue event is not fired properly.

My experience with script runner is limited, but it is likely you need to change the last line to fire an actual event, like 

EventDispatchOption.ISSUE_UPDATED

Hope that helps. 

Cheers,
  Anthony

Yves Martin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2020

Hello @Anthony De Moss Correct! It is required to fire event for macro replacement. I was not aware about it, and choose "do_not_dispatch" to avoid additional notification. Many thanks. Yves

Suggest an answer

Log in or Sign up to answer