Create Issue - Conditional assign user to a role using Misc Workflow Extension Edited

Good afternoon,

I have a workflow where I want the assigned person to be selected based upon a field the customer selects when using the Service Desk help center. It's a drop down menu called Topic, and right now it has three options: Batman, Robin, Joker

On the Create Issue transition I added a Post Function right after "Creates the issues origionally" step. I have the Project Role set to Administrators, and the conditional execution is this: 

 

 if (cfValues['Topic'].getValue() == "Batman"){ return true }

I have also tried:

{% if issue.fields["Topic"] == "Batman" %}
true
{%endif%}

I've tried several other statements I've found on the internet but haven't had any luck. I do know that when I remove the conditional it does assign the incident to the Administrators group accordingly. Ultimatley, what I want to have happen is the group the ticket gets assigned to is based on the drop down selection.

Any thoughts?

1 answer

0 vote

Hi Dan,

first of all, the "cfValues" syntax is from another add-on so it won't work in JMWE.

Did you read the documentation here: https://innovalog.atlassian.net/wiki/x/KICcBQ ? And in particular this page: https://innovalog.atlassian.net/wiki/x/bwBzBg ?

You should test the following condition code:

{{ issue.fields["Topic"].value == "Batman" }}

which is a shorter version of

{% if issue.fields["Topic"].value == "Batman" %}
true
{% endif %}

David.

Thank you for the reply, sir. 

Unforunatley, I'm still not having any luck. I did try

 

{{ issue.fields["Topic"].value == "Batman" }}

With the same result. Additionally, after reading those links I found the object ID of 10203, after examining the issue structure. This is what I saw. 

atlassian.net/rest/api/2/customFieldOption/10203","value":"Batman","id":"10203"},

Thus, I tried updating the code to 

{{ issue.fields.customfield_10203.value == "Batman" }}

and 

{{ issue.fields.customfield_10203.name == "Batman" }}

and neither have been successful. 

 

 

 

 

The numerical ID you found is that of the custom field Option, not the custom field itself. But anyway using the field name should work.

Did you try testing your template (using the "Test Nunjucks template" link) against an existing issue that has the expected value in the Topic field? If it doesn't return the expected value, try simply displaying the value:

{{ issue.fields["Topic"] | dump(2) }}

to see what exactly is the value of that field.

I just tried the Test Nunjucks Template and got a true result value when using this code:

{{ issue.fields["Topic"].value == "Batman" }}

I tested again with a different value and got false. So it does look like that's working as it should. Thank you for that. 

I am running it as an add-on user. Does that make a difference?

 

Unless the add-on is not properly installed (which can happen because of a JIRA Cloud bug), it shouldn't.

However, are you aware that Cloud post-functions are asynchronous and therefore their outcome is not always visible instantly?

If it still doesn't work, I suggest you open a support request at: https://innovalog.atlassian.net/servicedesk/customer/portal/10

Thank you for your help. I did notice one more thing, though

If I set the Project Role to Administrators the rule works without any problems. However, if I change it to something else (Developers, for example). It fails.

Is there something I could be missing?

Apart from some constraints on who can be assigned to issues, I don't see any reason why it wouldn't work. Unless of course these project roles are empty for that particular project.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

116 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you