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.
string issue.get("customfield_12230")
/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!
Thanks.
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:
"Batman"
or
issue.get("customfield_12230")
or
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.
FireShot Capture - Update Workflow Transition Set Field Va_ - https___jira.di2e.net_secure_admin_w.png
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hang on, that's different again. I'd go back to basics - does a plain fixed string work? E.g. just put in "Batman" or something obvious. Also, where did you get the " issue.get " type notation from?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any suggestions? This just feels so basic. And yet . . .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Im not doing that using groovy, im using this postfunction:
of this Add-on:
https://marketplace.atlassian.com/plugins/com.fca.jira.plugins.workflowToolbox.workflow-toolbox
In target field you use "Summary" and you can get values of any custom field available
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Guilherme, can you send some step by step to me so I can set this up?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One question, do you want to do that in a postfunction?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!
Join an Atlassian Community Event!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.