I'm trying to use a groovy expression to populate the summary field from a postfunction.
I want to string together the values of three custom fields and have that be the issue's summary.
Starting with baby steps, I'm trying to set the summary field to just one of the custom field values. No success.
I am NOT a groovy developer or any other kind of developer. Which is defintely a problem since I'm not sure what a groovy expression is.
When I put for following in for a groovy expression I get the error shown below.
/secure/QuickCreateIssue.jspa [jmwe.plugins.functions.SetFieldValueFunction] Error while executing SetFieldValueFunction: groovy.lang.MissingMethodException: No signature of method: Script1.string() is applicable for argument types: (java.lang.String) values: [Add] Possible solutions: toString(), toString(), print(java.lang.Object), sprintf(java.lang.String, [Ljava.lang.Object;), print(java.io.PrintWriter), sprintf(java.lang.String, java.lang.Object) groovy.lang.MissingMethodException: No signature of method: Script1.string() is applicable for argument types: (java.lang.String) values: [Add]
That's not bad considering that the value in the custom field is in fact "Add". But obviously it didn't work.
When I drop "string" I get no errors in the logs, but neither does it populate the Summary field.
All help appreciated. And if the answer can be in non-developer speak, even better!
A co-worker solved this for me. The key is when the post-function is called.
As I mentioned previously, This postfunction was the last post function run. It was after the postfunction that initially creates the issue. We moved it to be the first postfuntion called and everything works!
Specifically in the value field I can put:
issue.get("customfield_12230") + " " + issue.get("customfield_12003")
And they all work.
I want to thank everyone for their time and suggestions. I always start with Atlassian Answers because of all the smart people that are willing to offer their help.
yes. On the create issue. In the creation of the issue, the reporter will fill in (required) values for three custom fields. I want to string those values together to populate the summary field. Seems like a postfunction is the way to go. Do you have a different suggestion?
It looks like issue.get("customfield_12230") is returning an array, rather than a string. Is the field a multi-select or checkbox field?
Another quick dirty test would be to try issue.get("customfield_12230").toString() and see what that returns - if it's an array, you'll get an ugly string like "[ armadillo ] @ [ banananana ] @ [ minion ]", but at least it will be telling you something.
That custom field is a radio button with two options. I can't even get this to work with "reporter" inserted instead of the custom field. Per your suggestion I tried issue.get("customfield_12230").toString(). No errors in the logs. But nothing put in the Description field either. I tried another custom field which is a user. Nothing. No errors. No results. I tried issue.get("reporter").toString() too. Nada. By the way, that is ALL I have in the Value window. I hope it's not assumed that I've included some other key phrase. I'll attach a screenshot.
Im not doing that using groovy, im using this postfunction:
of this Add-on:
In target field you use "Summary" and you can get values of any custom field available
On reason for my choice of groovy is that after I get this (what I thought would be) simple thing to work, I want to use groovy to call a perl script and take the results of that perl script and add it to a comment or other custom field. So I'm hoping to learn the groovy way in baby steps. I do appreicate your suggesting another solution however.
FireShot Capture - Update Workflow Transition Set Field Va_ - https___jira.di2e.net_secure_admin_w.png
I like basics. The only thing now in the Value box is "Batman". Didn't work. No errors. But the description field was not updated. I also tried leaving "Batman" and changing Value type to "Raw Value". Same results. This postfunction is the last post function run. It is after the postfunction that initially creates the issue and after the Issue Created event is fired. Thanks for your patience. Where I saw the issue.get notation: https://answers.atlassian.com/questions/285260
Hmm. I'd say it's a bug in the JMWE then - putting in the string "Batman" should set the Summary to Batman. That's what the help and the documentation says - "return a string that will be converted", and "Batman" is exactly that. My only other thought is that maybe the JMWE expects an explicit "return", which feels wrong to me, as I thought it should just use the last evaluation or assert. So maybe try return "Batman"
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
We're bringing product updates and pro tips on teamwork to ten cities around the world.Save your spot