We are not able to get data from scripted custom field(single issue picker) to summary

Mahesh Kallepalli January 1, 2020

Hello ,

We are Having scripted custom field with type single issue picker which contains drop down of other issues.


We need automatically move that field value to the summary. We worked around some code through listeners but it is taking the only "HR-125" but it is not reading the rest of the text. Could you please help us to achieve that at least we don't need that HR-125 our target is that only the text besides that key has to replaced.

Please find below code which you are using through listener

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.fields.CustomField;
import groovy.json.JsonSlurper

def eventIssue = event.issue

if(eventIssue.issueType.getName() == 'Onboarding-Manager Submitted'){

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField EmployeeName = customFieldManager.getCustomFieldObject("customfield_11602");
//Employee name customfield_11601 of Onboarding-HR Initiated

def summaryValue;
def cfv1 = eventIssue.getCustomFieldValue(EmployeeName);
log.warn('EmployeeName '+cfv1)
if(cfv1)

{ summaryValue = cfv1 }

def im = ComponentAccessor.getIssueManager();
log.warn('EmployeeName TETE '+summaryValue.toString())
def issueToChange = im.getIssueObject(eventIssue.id) as MutableIssue
issueToChange.setSummary(summaryValue.toString())
//def im = ComponentAccessor.getIssueManager();
//def issueToChange = im.getIssueObject(issue.id) as MutableIssue

single issue picker.JPG

2 answers

0 votes
Leonard Chew
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 3, 2020

Hi Mahesh

If you have the key, you can get any data from that specific issue. In this example the summary of the key HR-125, which will probably be the name "John", if I understand your HR-Issue type correctly.

import com.atlassian.jira.component.ComponentAccessor

def cfv1 = "HR-125"
def issueManager = ComponentAccessor.getIssueManager()
def cfvIssue = issueManager.getIssueObject(cfv1)

log.warn('issue summary of HR-125 is: ' +cfvIssue.summary)

 

 

 

0 votes
NCATS LAB January 2, 2020

I'm unaware of any way to do this out of the box. You would need to parse the Employee name value and then update the Summary with this value.

 

There are a couple of add ons that could handle this easily. 

 

https://marketplace.atlassian.com/apps/6820/scriptrunner-for-jira?hosting=server&tab=overview

https://marketplace.atlassian.com/apps/29496/jira-workflow-toolbox?hosting=server&tab=overview

Suggest an answer

Log in or Sign up to answer