Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Add a value from one field to the end of the existing summary field value

Scott Federman March 8, 2018

I have a project selection field in my issue. I want to be able to take the project name from that field and add it to the end of the existing value in the summary field. Any ideas how i could do this?

1 answer

0 votes
Kyle Moseley
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.
March 8, 2018

You could do this fairly easily with a script post function (transition based) using ScriptRunner.

import com.atlassian.jira.component.ComponentAccessor

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("your field")
def cfVal = issue.getCustomFieldValue(cf).getValue()
issue.summary = issue.summary + " " + cfVal
Scott Federman March 8, 2018

okay great so when i create a ticket i require the "Related Project" field to have a project selected. So they will name the issue in the summary as "Issue A" and hit create. When they do so it will need to take the project from that field selected and add it to the end of the summary to show "Issue A - Project Name". 

I used the mentioned script but it didnt seem to work. I update with custom field "Related Project"

Kyle Moseley
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.
March 8, 2018

Try changing the order of your post-functions to make sure the scripted one is coming after issue creation. Also check logs (easily done from Built-in Scripts) to see what sort of errors you're getting on issue create.

Scott Federman March 8, 2018

Hey @Kyle Moseley

Thanks again for your help. I have it placed right after it reindexes the issue. 

Here is the error.

The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.

2018-03-08 11:42:00,568 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2018-03-08 11:42:00,569 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: RP-9, actionId: 1, file: <inline script>
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.project.ProjectImpl.getValue() is applicable for argument types: () values: []
Possible solutions: getName(), getClass(), getUrl(), getAvatar(), getAt(java.lang.String), getEmail()
 at Script10.run(Script10.groovy:4)
Kyle Moseley
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.
March 8, 2018

Looking at the error... mentions project objects. I assumed you were using a basic custom field, but either way look at the Project's API documentation. You may need to use a different method.

 

https://docs.atlassian.com/software/jira/docs/api/latest/com/atlassian/jira/project/Project.html

 

Like .getName()

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events