Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Radiobutton in post-function (Done transition) not updating

Deleted user November 22, 2018

HIya people.

 

I'm kind of new to transitions, so I'm not really sure if this is possible or not. I have a custom field of type Radio button (basically just a yes/no) which may be initially set creating an issue. What it should do is, if the radiobutton is yes, it should add a prefix to the comment and if no, no prefix. 

here is the codeblock:

import com.atlassian.jira.component.ComponentAccessor

def customFieldName = "User Communication"
def prefixComment = "*Public Comment*"

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def field = customFieldManager.getCustomFieldObjectByName(customFieldName)
def option = issue.getCustomFieldValue(field)
log.warn(field.getValue(issue))

for(String optionValue : field.getValue(issue))
{
log.warn(optionValue)
if(optionValue.equals("Yes"))
{
transientVars.comment = prefixComment + " " + transientVars.comment
}
else
{
// do something
}
}
 

 

Lets say the radiobutton is NO, and i go to workflow -> Done, and in the transition screen i want to change the radiobutton to yes (so it should add a prefix to the comment) the customfield doesn't seem to get "updated", it's still just the original value from the issue screen. 

So when i run my code, it prints out no and not "yes" as i selected in the screen..

 

Im using jira software 7.7.0

 

Is there any way to get the "updated" value of the customfield in the transitionscreen?

2 answers

0 votes
Tarun Sapra
Community Champion
December 10, 2018

Hello @[deleted]

Based on your use-case, you can do it on the post-function instead of in transition. Because you want to add a "prefix" in the comment.

def prefixComment = "*Public Comment*"

 Now, the prefix, has to be added based on the value of the custom value which can change during transition thus it will be better to make this prefixComment change after the transition is over i.e in the Post-function. Using APIs you can easily fetch the last comment of the issue and then check the final value of the custom field in the post-function and based on the value you can update comment.

0 votes
miikhy
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.
December 7, 2018

Hi Matias,

Welcome on Community!

Can you please share details on where the script execution is happening? I guess it's a post function but the order is very important (as storing the issue can happen after script execution?).

Also, have you tried using transientVars? It might (or not) be available depending when you're using the script!

Are your log.warn displaying the expected data? If not it might be how you access it.

Let us know if it helped, if not I'll reproduce and check more in details!

Cheers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events