Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Can JMWE Support Transitions as a result of Post Function

I would like a successful Post Function to Transition to one status, whereas an error would transition to a different status.


Is this capability supported?

2 answers

2 votes

Hi @Jonathan Towles 

since you want to trigger one transition if the REST call succeeds, and another transition if the REST call fails, the easiest is to use a single Transition Issue(s) post function and use a calculated transition, based on the result of the REST call.


The Calculated Transition script is:

{% if "$ref" | callRest(
body= { "": ("" +userid)},
params= { "groupid":groupid},
options= {
'auth': {
'bearer': token
headers: {
"ConsistencyLevel": "eventual"
) | field("_statusCode") != 204
To Pending
{%- else -%}
To Done
{% endif %}

Note that  field("_statusCode") != 204 is a little fake, as in reality _statusCode will only be returned in case of an error. So basically you could just test field("_statusCode") != null

Also note the added dontFail=true parameter.

"To Pending" is the name of the transition that needs to be triggered if the REST call fails, and "To Done" is the name of the transition that needs to be triggered if the REST call succeeds. Ideally, you should replace them with transition IDs (numbers) instead of names, in case you later rename the transitions.

0 votes

@Jonathan Towles -

What do you mean by "whereas an error would transition to a different status"?  Can you clarify and provide "Error" definition?

Are you saying that if something goes wrong in the post function call, you want a different status to be transition into?.  

Please advise.

Best, Joseph Chung Yin

Jira/JSM Functional Lead, Global Infrastructure Applications Team

Viasat Inc.

As in if the post function returns a 200 aka it was successful it transitions to done, but failures transition back to pending 

Thanks for the update.

In this case, you will need to have multiple post-function calls (i.e. multiple "Transition Current Issue Post-function" setup) and within those calls use "condition execution" setup - One for "Done" and other one for "Pending"


The key is to have a custom post function that will populate a field with the "200 aka" value prior to your ""Transition Current Issue Post-function"" calls.  So your JMWE post function for the WF transitions can detect the return value.

Hope this makes senses.

Best, Joseph

I'm not sure how I would do that if the previous post function is what returns that upon success.


Wouldn't you more likely build something into the initial post function with an if statement or something? An example if you have one would be really helpful as this is new to me.

You can use JMWE "Scripted (Groovy) operation on issue" post function call to construct your IF logic to set the custom field with the returned value.  Take a look at -

If you are familiar Groovy, then you can even just use the post function above to conduct your issue transition... Here is an example posting on using Groovy script to transition issues - 

Best, Joseph

I might be confused so let me show you what I'm doing.


The end result is I have a Post that does this: (Adds a Member to an AD Group in Azure) Basically, once the ticket is approved, it transitions to "implementing" and the event-based action will do this callRest:


) | field("value") | first | field("id") %}
{{"$ref" | callRest(
body= { "": ("" +userid)},

params= { "groupid":groupid},
options= {
'auth': {
'bearer': token
headers: {
"ConsistencyLevel": "eventual"
) | dump(2)


When you run that command it will return something like this:

HTTP/1.1 204 No Content


What I am trying to do is to get a transition from Implementing --> Done if the callRest returns a HTTP/1.1 204 No Content

What process in your Jira env conducting event based the callRest.  You may need to conduct this process where event is fired and then conduct the transition via Jira REST APIs custom program.

I am not a technical developer, so I cannot provide you with Jira REST APIs programming.

Best, Joseph

I set it as an Event-Based Action and POST function within there within JMWE

Don't know if this helps - In the JMWE Event based wiki page section -

Passing variables within a sequence
"Using the {% setContextVar %} Nunjucks tag you can pass data from one post-function to all subsequent post-functions."

It seems you can captured the return value from a event-based action, and then it can be referenced in the sequent post function calls.  You can then reference the variable in the Condition execution in the Transition Issue Status post function.

I have not use JMWE event-based action yet, thus I cannot provide more detailed information for your ask.  You may want to submit a support request to JMWE vendor for suggestion.

I look forward to their response to your ask.

Hope this helps.

Best, Joseph

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events