Default Jira massage has shown instead workflow validator massage

Noa Masel February 2, 2021

hello

I wonder if it's a bug or not,

I added workflow validator (Simple scripted validator of ScriptRunner).

The validator works as expected at the "create" step but not at the "resolve". If the script returns a false value the transition will be blocked with the error message I have defined. but at "resolve" stage its return default Jira massage:

"It seems that you have tried to perform an illegal workflow operation.

If you think this message is wrong, please contact your JIRA administrators."

In this to transitions there is no configured screen.

 

Thank you! 

Noaimage.png

3 answers

1 accepted

1 vote
Answer accepted
Italo Qualisoni [e-Core]
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.
February 3, 2021

Hi @Noa Masel ,

 

Welcome to Atlassian Community!

In my understanding, when you opt to use the "Simple scripted validator", you need to add in your code the instructions to display a message explaining the reason that the Validator failed.

See below example from Scriptrunner documentation, where it throws an InvalidInputException exception if the issue has no fix versions during its closure transition. 

import com.opensymphony.workflow.InvalidInputException

if (issue.getResolution() == "Fixed" && ! issue.fixVersions) {
throw new InvalidInputException("fixVersions",
"Fix Version/s is required when specifying Resolution of 'Fixed'")
}

https://scriptrunner.adaptavist.com/latest/jira/tutorials/scripted-validators-tutorial.html#__em_custom_script_require_fix_version_em

Can you include this exception in your validator script and let me know the outcome?

Noa Masel February 3, 2021

Thank you @Italo Qualisoni [e-Core] 

My script is checking if the custom field SR-type filled while user open SR ticket.

My simple script  is:

cfValues.get("Service Request Type")?.keySet()?.size() == 2image.png

As I wrote, the validator works as expected at the CEREATE transition, but not at the RESOLVE transition (I added the same validator at the resolve transition because sometimes the ticket opened as bug or task instead of SR, and when I move it to SR the ticket already created and validator doesn't work on the other transition, so before I close the ticket I want to validate if the SR-type field is filled...).

As you can see the massage is not part of the script.

Thank you!

Italo Qualisoni [e-Core]
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.
February 4, 2021

Hi @Noa Masel ,

I was mistaken, you need to throw InvalidInputException when using the "Custom script validator".

My guess is that your transition don't have a screen and this might be part of your issue.

As a test, can you create a Screen containing your "Service Request Type" field and associate this screen in your resolve transition? Let me know if does this fix your issue.

I'm not sure if not working with none screen is a bug or expected behavior, I might need to open a ticket to Adaptavist to get their response on that.

Noa Masel February 4, 2021

Thank you @Italo Qualisoni [e-Core] I'll try and let you know!

0 votes
Denis Zvonov March 8, 2022

Same thing here with Power Scripts, started after upgrade to 8.20.6

0 votes
Randy
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.
February 3, 2021

Expected.  Not giving the user a reason for the failure is the primary reason we usually avoid using validators.  It just introduces confusion.

Suggest an answer

Log in or Sign up to answer