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?
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.