Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Assign to role member based on cascading select values on create

Anatolijs Tarasovs March 11, 2015

Hi,

I need to assign an issue to a role member based on cascading select values when an issue is created. I can do this with a single select value like this.

issue.get("customfield_10900") == "Value"

However, I cannot figure out how to do it with a cascading select. I've tried the following among other options:

issue.get("customfield_10901").get(null) == "Parent" && issue.get("customfield_10901").get(1) == "Child"

It doesn't throw an error, but also doesn't assign as I'd expect. The expression need to evaluate to true in order for post function to work.

What am I missing?

Thank you,

Anatolijs

6 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
David _old account_
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.
March 19, 2015

I found it: that's because issue.get("customfield_10900").get(null) will actually return an Option object, not a string. So you need to call "getValue()" on it before comparing it to a String.

issue.get("customfield_10900")?.get(null)?.getValue() == "Marketing" && issue.get("customfield_10900")?.get("1")?.getValue() == "Marketing Communications")
Anatolijs Tarasovs March 19, 2015

Great, thanks so much, it finally works. I really appreciate your help! I guess that the nature of post-functions that it could only be used and configured once in a transition, but what would I do if I wanted to assign to another role if the value of this cascading field (or any other field) would be different?

David _old account_
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.
March 19, 2015

For historical reasons, this post-function was marked as "single-use" in a transition. This will be changed in the next version of the plugin.

Anatolijs Tarasovs March 19, 2015

That's great news. Thanks so much for all the help, David!

Anatolijs Tarasovs March 24, 2015

When do you plan to release the next version of the plugin?

David _old account_
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.
March 27, 2015

Hopefully beginning of April.

0 votes
Anatolijs Tarasovs March 16, 2015

Great, that does get the child value, however, it does not assign the issue to the role. It seems that it doesn't evaluate to true for some reason. I know that the role is valid and set correctly since the post-function worked if I compared against a single select custom field value.

Do you have any ideas?

Your help is much appreciated.

Anatolijs

Screen Shot 2015-03-16 at 15.54.13.png

Screen Shot 2015-03-16 at 15.55.06.png

 

David _old account_
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.
March 16, 2015

You should first try to deactivate the condition and make sure the assignment then works. Then you can add some logging: log.error("will transition: "+(issue.get("customfield_10900").get(null) == "Marketing" && issue.get("customfield_10900").get("1") == "Marketing Communications")); and then look at the end of atlassian-jira.log

Anatolijs Tarasovs March 17, 2015

It worked with deactivated condition. The issue was assigned to the role. The log contained the following after enabling the condition: 2015-03-17 08:26:07,146 http-bio-8443-exec-576 ERROR atarasovs 506x565545x1 qbxu9l 10.22.160.81 /secure/QuickCreateIssue.jspa [jmwe.plugins.functions.AssignToRoleMemberFunction] will transition: false I did select the right values in the cascading select list.

David _old account_
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.
March 17, 2015

Then try outputting the field values: log.error("parent: "+(issue.get("customfield_10900").get(null)+", child: "+(issue.get("customfield_10900").get("1"));

Anatolijs Tarasovs March 19, 2015

I tried the outputting both: log.error("will transition: "+(issue.get("customfield_10900").get(null) == "Marketing" && issue.get("customfield_10900").get("1") == "Marketing Communications")); log.error("parent: "+(issue.get("customfield_10900").get(null))+", child: "+(issue.get("customfield_10900").get("1"))); The log showed the following: 2015-03-19 06:39:53,525 http-bio-8443-exec-650 ERROR atarasovs 399x613931x1 138997t 10.22.130.2 /secure/QuickCreateIssue.jspa [jmwe.plugins.functions.AssignToRoleMemberFunction] will transition: false 2015-03-19 06:39:53,526 http-bio-8443-exec-650 ERROR atarasovs 399x613931x1 138997t 10.22.130.2 /secure/QuickCreateIssue.jspa [jmwe.plugins.functions.AssignToRoleMemberFunction] parent: Marketing, child: Marketing Communications So it seems it gets the right values, but why would they evaluate to false?

0 votes
David _old account_
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.
March 11, 2015

To access the "child" value, you must use get("1"), not get(1):

issue.get("customfield_10901").get(null) == "Parent" && issue.get("customfield_10901").get("1") == "Child"
0 votes
Anatolijs Tarasovs March 11, 2015

So it looks like it is picking up the parent value, but not the child value. I also tried get(0) and the outcome was the same.

0 votes
Anatolijs Tarasovs March 11, 2015

Create Issue dialog throws an error: Error creating issue: null when I add the above code. The log says the following: "parent: Marketing child: null", even though the child value is set and definitely isn't null.

0 votes
David _old account_
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.
March 11, 2015

Did you try logging the values to see what you're actually getting? {code} log.error("parent: "+issue.get("customfield_10901").get(null) +" child: "+issue.get("customfield_10901").get(1)); {code}

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events