Get the value of a custom field during a trantision

Oded Priva June 25, 2014

Hi,

What is the syntax to get a custome field value during a transition?

let me elaborate :

I have a screen that shows a custome field which the user can change, I would like to get the updated value of this field in a groovt scirpt I'm running as part of the transition.

3 answers

1 accepted

0 votes
Answer accepted
Tsol
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 25, 2014

Try something like the following

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;


CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();

CustomField customField_test = customFieldManager.getCustomFieldObject( id );


def test_value = issue.getCustomFieldValue( customField_test )

Oded Priva June 25, 2014

Don't I need to use something with transientVars ?

Tsol
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 25, 2014

Yes you could use it. A related question is here

I think the script i have provided will do the job for you if the sequence of postfunctions is right. Test it first. I use something similar in some postfunctions and works fine.

JamieA
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 29, 2014

cfValues['Name of field'] should work

Oded Priva July 1, 2014

The regular way as suggested here worked just fine .

When do one need to use transientVars["issue"] ?

0 votes
Paresh Gandhi
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 30, 2014
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.ComponentManager
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
cfParent = customFieldManager.getCustomFieldObjectByName('Computer Needs')
parentMyFieldValue = transientVars["issue"].getCustomFieldValue(cfParent)

0 votes
Paresh Gandhi
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, 2014

may be

transientVars["issue"].CustomFieldId

It works for

transientVars["issue"].Summary etc

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events