The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

JMWE Expression for Conditional Issue Creation

Fredson N_
Contributor
November 7, 2023

Hello

I am currently configuring a 'Create issue(s)' post-function in Jira Cloud using the JMWE add-on and am having some trouble setting up a conditional expression that determines the destination project for new ticket creation.

This is a issue escalation process from JSM to Jira software.

I want the destination project for creating a new ticket to be determined by the value of a "Request Type" field and a cascading "Asset" custom field. The conditions are as follows:

  1. If the request type is "Office Service Request" or "Report Office Incident", the new ticket should be created in the project corresponding to the planet "Mercury".
  2. If the request type is "Report an Incident for an Application or System" or "Service Request for an Application or System", the destination project should be determined by the value of the "Asset" field:
    • If Asset = "Moon", then the destination is the planet "Lunar".
    • If Asset = "Mars", then the destination is the planet "Martian".
    • If Asset = "Saturn", then the destination is the planet "Saturnian".
    • For any other value of "Asset", the destination project should be "Mercury".

Using Jira expression syntax, I'm receiving a 400 error when executing the post-function. Here is the expression I attempted:

 

(issue.fields.customfield_10605.requestType.name == 'Office Service Request' || issue.fields.customfield_10605.requestType.name == 'Report Office Incident') ? 'Mercury' : (issue.fields.customfield_10605.requestType.name == 'Report an Incident for an Application or System' || issue.fields.customfield_10605.requestType.name == 'Service Request for an Application or System') ? (issue.fields.customfield_18708 && issue.fields.customfield_18708.value == 'Moon' ? 'Lunar' : issue.fields.customfield_18708 && issue.fields.customfield_18708.value == 'Mars' ? 'Martian' : issue.fields.customfield_18708 && issue.fields.customfield_18708.value == 'Saturn' ? 'Saturnian' : 'Mercury') : DefaultProject;

Could you help me understand where I might be going wrong in constructing this expression? Is it an issue with the Jira expression syntax or an issue with how JMWE processes the expression?

Thanks

Fredson

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
David Fischer
Community Champion
November 7, 2023

Hi @Fredson N_ 

the expression for the Calculated destination Project is a Nunjucks template, not a Jira Expression. You can therefore try this:

{% if issue.fields.customfield_10605.requestType.name == 'Office Service Request' or issue.fields.customfield_10605.requestType.name == 'Report Office Incident' %}
Mercury
{% elif issue.fields.customfield_10605.requestType.name == 'Report an Incident for an Application or System' or issue.fields.customfield_10605.requestType.name == 'Service Request for an Application or System' %}
{% if issue.fields.customfield_18708.value == 'Moon'%}
Lunar
{%elif issue.fields.customfield_18708.value == 'Mars'%}
Martian
{%elif issue.fields.customfield_18708.value == 'Saturn'%}
Saturnian
{%else%}
Mercury
{%endif%}
{%else%}
DefaultProject
{%endif%}
Fredson N_
Contributor
November 10, 2023

Hi @David Fischer 

Just wanted to drop a quick note to let you know that the code worked perfectly! I really appreciate your help in resolving this issue. Thanks a ton for your support!

Regards,

Fredson

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events