I am trying to translate the following in to a Groovy script and I am a complete noob when it comes to scripting. I can read a script and figure out for the most part what it should do but writing one is a completely different thing.
If Platform Engineering Team = Platform EU
I am trying to use this to assign a ticket to a role on create if the custom field (Platform Engineering Team) has value (Platform EU) set.
Please help me out.
Assuming this field is a select list, you could use:
if (cfValues['My Single Select']?.value == "Some value")
or do it the long-hand way, there are lots of examples of that here and in the docs: https://scriptrunner.adaptavist.com/latest/jira/
Always a fun day here on Atlassian Answers.
Daniel, the docs are listed here – https://innovalog.atlassian.net/wiki/display/JMWE/Post-functions. In this case, something like this should be close –
if ( issue.get("customfield_12345")?.value == "Platform EU" )
New error on ticket creation with that in place.
Error creating issue: startup failed: Script1.groovy: 1: unexpected token: @ line 1, column 62. 01")?.value == "Platform EU" ) ^ 1 error
I found two old questions that seem to have a similar error.
I took out the extra spaces in the script above from @Steve Behnke [DiscoverEquip.com] and the error just changed the column number to 60.
Thanks for the help and at least getting me to this point.
All the whitespace seems to be garbage, I am not sure why. The script condition I wrote has exactly 57 characters in it, so be sure to get all the whitespace out. I cleaned it up here, but I still haven't had time to test this further, sorry –
With no spaces what so ever I get the same error with the number being 57. Just to confirm that the plug in was working and it was just an issue with the Groovy in the field I removed the check from " Only if condition is true " and it did as it should. I need the Groovy to work or there is no sense in having the auto-assign option because it will be sending it to the Platform EU team.
Hey @Steve Behnke [DiscoverEquip.com],
You have been great. I removed the IF and now it is not throwing an error. It is not assigning it but that is not a fault of the script as much as the plugin. Now to figure out why that might be. I have checked roles and permissions for the project I am testing on which matches the project this is ultimately going in to.
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...
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!
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