Forums

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

How to add smart value of any field in the summary of cloned issue in the post functions script runn

Ramesh Kale June 20, 2019

In the post functions Script runner clone issues:

To Update Cloned issue Summary, the default script given is

issueInput.fields.summary = "${issueInput.fields.summary} was Cloned by my Script"

However i want to add parent key and value of field 'Country' from parent issue into the cloned issue summary.

i.e. I want country name from parent issue and parent key in Cloned issue summary.

For example: "India Issue-12 This is TEST issue".


I am running following commands but it is not working. :-(

1st command

issueInput.fields.summary = "${issueInput.fields.country} ${issueInput.parent.key} This is TEST issue"

2nd command

issueInput.fields.summary = "{{issue.fields.country}} {{parent.key}} This is TEST issue"

3rd command

issueInput.fields.summary = "{{Country}} {{parent.key}} This is TEST issue"


Please help.

 

 

1 answer

0 votes
Aleksandr Zuevich
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.
June 21, 2019

Hi,

This should work for you case:

def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == 'Country'}
def countryValue = sourceIssue.getCustomFieldValue(cf).toString()
issue.summary = countryValue + ' ' + sourceIssue.key + ' Communication Initiated'

Ramesh Kale June 26, 2019

Thanks, 

CustomFieldManager class is to be defined before the script you provided, I believe I need to find the replacement for the below import statements - as it is not accepted in the script. Any thoughts what should I use instead of following to import the class and define customFieldManager

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager

def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == 'Country'}
def countryValue = sourceIssue.getCustomFieldValue(cf).toString()
issue.summary = countryValue + ' ' + sourceIssue.key + ' This is TEST issue'

Regards

Aleksandr Zuevich
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.
June 26, 2019

I've just checked. I just input these three rows and everything works fine:

Capture.PNG

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events