It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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

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)

 

 

 

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you