Forums

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

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

Dan Schmidt June 19, 2017

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 votes
David Fischer
Community Champion
June 19, 2017

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.

Dan Schmidt June 19, 2017

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. 

 

 

 

 

David Fischer
Community Champion
June 19, 2017

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.

Dan Schmidt June 19, 2017

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?

 

David Fischer
Community Champion
June 19, 2017

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

Dan Schmidt June 19, 2017

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?

David Fischer
Community Champion
June 19, 2017

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
TAGS
AUG Leaders

Atlassian Community Events