I am working with JMWE and trying to write a groovy script where I want to check whether the summary of a ticket contains a specific string and then assign a ticket to a specified user if it does.
For example:
if (issue.get("summary").toLowerCase().contains("Check Refund")) { 'user1'}
if (issue.get("summary").toLowerCase().contains("Vendor Credit Memo")) { 'user1'}
if (issue.get("summary").toLowerCase().contains("Credit and Rebill")) { 'user1'}
else { 'user2'}
Is there a way to make this work? I am putting this post function on the 'create' workflow transition. I am also wondering if there is a functional wildcard to place within the quotes to parse any instance of the string, such as ("*Check Refund*").
Hi Josh,
yes, this can work. However, there are two problems with your code:
A fixed version of the script would be:
if (issue.get("summary").toLowerCase().contains("check refund")) {return 'user1'}
if (issue.get("summary").toLowerCase().contains("vendor credit memo")) {return 'user1'}
if (issue.get("summary").toLowerCase().contains("credit and rebill")) {return 'user1'}
return 'user2'
Thanks, David!
This checks out when I test the groovy script to an existing ticket.
What I should have mentioned in the original post is that my goal for this post function was to take a ticket that is created by an email handler and assign it based on what the summary contains. Do you know if this is possible?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Josh,
it is very unlikely that the email handler can skip the Create transition. That's the only way to create issues in Jira. Can you double-check?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
Brilliant! Upon further testing, I was still having issues - this was due to another post function counteracting the revised logic that we just discussed up above. Once that was removed, everything appears to be working just great!
Thank you for your help!
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.