ScriptRunner Fields Changed Validator - No message shown to user

Stephen Hodgson June 30, 2021

I'm using ScriptRunner's Fields Changed Validator to make sure the Time Spent (the validator notes this as "Log Work") field is changed during a workflow transition.  I can see that this validator is accurately preventing the transition from working if Time Spent is not entered on the transition screen, however this validator doesn't tell the user what is wrong - the transition screen just sits there until the user guesses at the field that is preventing the transition.

Using the latest ScriptRunner and Jira Software Server LTS at the moment.

2 answers

1 accepted

1 vote
Answer accepted
Irfan Mazuki July 13, 2021

A quick workaround is to use Simple Scripted Validator instead. I found this Community discussion that can be useful for this case. 

The script to be used:

import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue

Map<String,ModifiedValue> modifiedValues = ((MutableIssue)issue).getModifiedFields();

return modifiedValues.containsKey("worklog")
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 13, 2021

Nice find. 

I'm not super familiar with the getModifiedFields() method.

Stephen Hodgson July 14, 2021

Thanks for the workaround, I confirmed this works on the dev/test server.

1 vote
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 30, 2021

This seems like something you should report to productsupport.adaptavist.com/servicedesk

But if you don't want to wait for a fix, you can create a simple scripted validator instead:

2021-06-30 17_43_15-Add Workflow Function Parameters.png

Stephen Hodgson July 13, 2021

Thanks for the suggestion, but the simple scripted validator doesn't work.  If I put time in the Time Spent field during the transition it still throws the validation message.  We've had this issue forever with checking for issue links added during transitions as well.

I'll see where I can get with Adaptavist support.

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 13, 2021

You are correct, I obviously hadn't tested my suggestion.

Like you, I can't figure out how to access the log work details submitted as part of a transition screen.

But maybe I can suggest a different workaround using behaviour. It's still not perfect.

2021-07-13 09_28_45-Window.png

This issue I have here, is that the message is only visible when you've checked the "log work" box to expand and view the dependent fields. The form is still prevented from submitting, however. So maybe tagging the error to another field would be necessary

Suggest an answer

Log in or Sign up to answer