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?
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
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"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.