Groovy Post Function Script needs to be executed twice for result

Hemanshu Sood November 26, 2018

Hi All,

I have a workflow button "In progress" which helps me to move forward in  the ticket life cycle.

In the workflow post function: I want 2 things to happen:

1) Update a Select list based on a condition: I am using below script for this:

cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf), option), changeHolder); 

2) Since I am using 5 select lists, based on their values, i need to move ticket to a particular stage in workflow, say "Intermediate". I  am using the below script for this:

 

WorkflowTransitionUtil workflowTransitionUtil = JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
workflowTransitionUtil.setIssue((MutableIssue)issue);
workflowTransitionUtil.setUserkey(currentUser.getKey());

workflowTransitionUtil.setAction(301);
if (workflowTransitionUtil.validate().getErrorMessages().size() == 0)
{
workflowTransitionUtil.progress();
}

 

2 scripts in my post function, however to execute them both, I need to press "In progress" button twice in my Ticket view window.

Am i missing something ? is there  way to combine both the scripts to 1 to avoid pressing the button twice?

 

Please help

 

1 answer

1 vote
Danyal Iqbal
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.
November 26, 2018

i need to move ticket to a particular stage in workflow, say "Intermediate"

Workflow transitions in post function scripts is generally a bad idea. Please reconsider your workflow.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 26, 2018

"generally a bad idea" - that is a very polite way of saying "do not do this".

Hemanshu Sood November 26, 2018

Hi @Nic Brough -Adaptavist- @Danyal Iqbal 
the requirement states that based on the value of 5 Select lists(which are updated via post function) , ticket either needs to move to Stage A or B or C.

Any other way to accomplish this?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 26, 2018

Use Scriptrunner's "fast track transition" function.  This moves an issue on without the horror of trying to do a transition inside a transition inside a transition inside a transition  inside a transition  inside a transition  inside a transition ...

Hemanshu Sood November 27, 2018

Thanks @Nic Brough -Adaptavist-.

But with the help of Fast Track Transition an issue, can the transition for subtasks also be made i.e.

based on the value of 5 Select lists(which are updated via post function in the parent), if subtask needs to move to stage A or B or C?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 28, 2018

That is not what your original question asked.

You can transition other issues in a post-function, you don't need the fast-track - that is only for the current function.

Suggest an answer

Log in or Sign up to answer