Is there a way to set a custom field value with script listener

Tobias_Vollmer November 28, 2014

Hi,

we would like to set a custom field value on an event. At the moment, we already have a script listener sending out email notifications. Can we add setting the field to this listener?

And: If we can, please give a hint on how to set it.

2 answers

0 votes
Hung Nguyen January 6, 2015

Does Groovy script do this only after user Submits the form?

Is there any event fired right after a field is modified (new option selected, text filled in) that Script Runner can catch it even before the form submitted?

0 votes
RVal
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.
November 28, 2014

Below Groovy example is to set text Custom Field

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
 
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def cf1 = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'cf1Name'};
 
def changeHolder = new DefaultIssueChangeHolder();
cf1.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf1), 'newCf1Value'), changeHolder);
 
issue.store();
Sandra Meessen August 16, 2018

Hello,  Does this also work for my custom field of type "select list (single choice)"?

Judah October 24, 2018

@RVal

I have the same question as @Sandra Meessen

I am trying to copy the value of my "select list (single choice)" from parent to child on an issue created event. 

What would that script look like? 

Suggest an answer

Log in or Sign up to answer