want to populate summary field with concatenation of three custom field values

DI2E Licensing
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2015

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!  smile

Thanks.

 

 

6 answers

1 accepted

0 votes
Answer accepted
DI2E Licensing
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2015

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.

 

0 votes
DI2E Licensing
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2015

FireShot Capture - Update Workflow Transition Set Field Va_ - https___jira.di2e.net_secure_admin_w.png

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 30, 2015

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?

DI2E Licensing
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2015

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

DI2E Licensing
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2015

Any suggestions? This just feels so basic. And yet . . .

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 2, 2015

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"

0 votes
Guilherme Nogueira
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2015

Im not doing that using groovy, im using this postfunction:

 

https://bitbucket.org/fcarmario/jira-workflow-toolbox/wiki/post-functions/Copy%20Parsed%20Text%20to%20a%20Field.wiki

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

DI2E Licensing
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2015

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.

Sam Talkers June 28, 2018

Guilherme, can you send some step by step to me so I can set this up?

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 30, 2015

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.

DI2E Licensing
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2015

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.

0 votes
DI2E Licensing
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2015

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?

0 votes
Guilherme Nogueira
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2015

One question, do you want to do that in a postfunction?

Suggest an answer

Log in or Sign up to answer