Hello all!
I am new to JMWE and Groovy, used to using Automation for Jira, but that's not an option with our current projects, so I may be trying to oversimplify this.
We are using ProForma Forms to create a ticket and I want to be able to conditionally set the Priority using the custom field "Severity" that we have on our ProForma (the severity cases that users see are different from what our Jira team uses, so I want each team to see it the way they are used to.
I have an event-based action for when an issue is created that uses the postfunction "Set field value (JMWE app)". I believe I have structured my if/else ladder correctly, but I think I need to add something to the first line to get this to call properly. My current script to set field Priority (using our custom field Severity, which is number 17508, I have triple checked this) looks like this:
if(issue.get(customfield_17508 == Critical))
{
priority == Urgent
} else if(issue.get(customfield_17508 == Serious))
{
priority == "High Importance"
} else if(issue.get(customfield_17508 == Moderate))
{
priority == "Medium Importance"
} else if(issue.get(customfield_17508 == Minor))
{
priority == "Low Importance"
} else (issue.get(customfield_17508 == unknown))
{
priority == "Not Prioritized"
}
Every time I test the script I get the below error on the first line:
groovy.lang.MissingPropertyException: No such property: customfield_17508 for class: script_2b3e01598fee06c177c8fbd94a015888
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:65) org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:51) org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:309) script_2b3e01598fee06c177c8fbd94a015888.run(script_2b3e01598fee06c177c8fbd94a015888.groovy:1)
Any ideas on what I can add or adjust to get the script to run properly? Like I said, I'm VERY new to groovy, so I fully expect there to be context errors above and appreciate anyone's help who can give me some insight!
TIA
Hi @Cailin Che ,
Your Groovy expression is actually somewhat incorrect. The correct version would be:
if(issue.get("customfield_17508") == "Critical")
return "Urgent"
else if(issue.get("customfield_17508") == "Serious")
return "High Importance"
else if(issue.get("customfield_17508") == "Moderate")
return "Medium Importance"
else if(issue.get("customfield_17508") == "Minor")
return "Low Importance"
else
return "Not Prioritized"
But it might actually not work if customfield_17508 is set by ProForma Forms, as I believe the app doesn't set the field value in time for the event-based action to see it. I remember discussing this problem with the ProForma team and they didn't have a solution at the time. But maybe Atlassian fixed it after the acquisition.
That worked! Still have to see if it works in real time, but at least the test script worked correctly!
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.