Get the value of a custom field during a trantision

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

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 )

Don't I need to use something with transientVars ?

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.

cfValues['Name of field'] should work

The regular way as suggested here worked just fine .

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

may be

transientVars["issue"].CustomFieldId

It works for

transientVars["issue"].Summary etc

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)

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

176 views 0 4
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you