how to get field value from screen in transition post function ?

Sergio Renzo May 28, 2020

guys,

I'm newly in JIRA development .

I'm developing a QA workflow and for some transitions I'll present to user a screen where I'll get some data to create a sub-task to address the develop team to fix something and get back to continue the QA workflow ... how can I get the screen's field to allow me to create the sub-task from post function groovy script ? 

1 answer

1 accepted

0 votes
Answer accepted
Danyal Iqbal
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.
May 28, 2020
import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def transitionfield = customFieldManager.getCustomFieldObjectByName("Name of the field")

def Value = issue.getCustomFieldValue(transitionfield)

Once you have the value, you can use it to create the subtask. You might have to experiment with the order of this script in your transition post functions.

However, this is a bad practice.....don't do it.... you would be better off creating a new transition for each possible value of the transitionfield and let the user select the correct transition.

Greetings.

Sergio Renzo May 28, 2020

hello Danyal - thx for your response ...

I have to bother you a little bit:

when I run in the script console for test the code I'm getting the error below:

 

Annotation 2020-05-28 101224.pngI can't fix it ... sorry ...

Sergio Renzo May 28, 2020

any ideas ?

Sergio Renzo May 28, 2020

never maint ... I did realize that issue... will only be available on Post Functions, Validators and behaviors not at Console ... sorry ... I told you I'm newly ... 

Danyal Iqbal
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.
May 28, 2020

seems like you figured it out yourself.

you could also use

def Issue issue = issue

 to define the issue, but it is probably excessive.

Sergio Renzo May 28, 2020

yep ... thx MAN !!!

Suggest an answer

Log in or Sign up to answer