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
Community moderators have prevented the ability to post new answers.
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")
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When do you plan to release the next version of the plugin?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hopefully beginning of April.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Then try outputting the field values: log.error("parent: "+(issue.get("customfield_10900").get(null)+", child: "+(issue.get("customfield_10900").get("1"));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.