How to concatencate custom fields into summary on "Create"

Hi Atlassian Community!

Hopefully someone could help me out here. I need assistance on populating two custom fields into the Summary field that I will hide on my screen during the filling out of the issue/ticket.

I found this script online, but I'm having issues implementing it via Script Runner.

package UpdateIssue
 
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
 
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
 
issue.setSummary(customFieldManager.getCustomFieldObjectByName(“Legal Name”).getValue(issue).toString() + "/" + customFieldManager.getCustomFieldObjectByName(“Project Name/Code”).getValue(issue).toString())

I added this script by editing my workflow, going to Post Function in "Create."

When adding Post Function,  used "Script Post-Function, and added the script (above).

Now, I'm receiving this error below.

The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
2017-11-30 14:13:00,637 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2017-11-30 14:13:00,648 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: null, actionId: 1, file: <inline script>
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.issue.managers.CachingCustomFieldManager.getCustomFieldObjectByName() is applicable for argument types: (java.lang.Integer) values: [10900]
Possible solutions: getCustomFieldObjectByName(java.lang.String), getCustomFieldObjectsByName(java.lang.String)
    at UpdateIssue.Script18.run(Script18.groovy:9)

 

Any help here would be greatly appreciated.

 

 

1 answer

1 accepted

1 vote
Jenna Davis Community Champion Dec 04, 2017

Hello, 

What version of ScriptRunner are you currently using? You may need to make a few changes depending on that. 

Jenna

Hi Jenna,

Thanks for chiming in, I'm using ScriptRunner v5.2.2. and Jira v7.2.6.

Hello, 

Thanks! 

After-reading your question I realized you're trying to do this on the create transition, which I don't think will actually work unfortunately.

I would recommend following the suggestion to use behaviours in order to do this from this question:

https://community.atlassian.com/t5/Answers-Developer-Questions/Groovy-Set-issue-summary-in-post-function-on-create/qaq-p/499306

Please let me know if you need any more help!

Jenna Davis

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,337 views 14 20
Join discussion

Atlassian User Groups

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!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot