Hi Team,
Forgive me if it comes up as a silly question since I am a complete beginner to Scriptrunner. I am trying to add the following validator script to Workflow but getting the following error.
cfValues['Sub-Status']*.value.contains("On hold")
Here 'Sub-Status' is a checkbox field having only 1 value 'On hold' currently.
Could you please help me with the solution?
Thanks and Regards
Danish Hussain
Hi Danish,
Thank you for your question.
I can confirm that the reason for your error is due to your validator expression is not valid code for Jira cloud and is groovy code that will only work on Jira server.
I can confirm that inside of Jira Cloud that validators are designed using the Jira Expression Framework and you would need to use this expression syntax to define the validator that you require.
I can confirm that we have a knowledge base article located here which explains how you can use this to create the validator that you want with ScriptRunner for Jira Cloud and I hope this helps to achieve your requirement.
I hope this information helps.
Regards,
Kristian
Hello @Kristian Walker _Adaptavist_ ,
Thank you for the above links.
I was able to find scripts related to labels, links, discription, sub-tasks etc. but unable to get anything regarding Checkboxes.
If possible, could you provide a code similar to cfValues['Sub-Status']*.value.contains("On hold") for JIRA cloud?
Thanks in advance,
Danish Hussain Sabunwala
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Danish,
I have added an example here on line 55 which shows gow to validate that a checkbox field must contain just a single value.
Please note if you need to change this example you will be able to modify this using the Jira Expression framework doucmentation as an example to help you to modify it using the Jira Expression framework doucmentation as a guide to help you to achieve this.
I hope this helps.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Kristian Walker _Adaptavist_ ,
Thanks a lot for your help. The following code provided the answer I was looking for.
Regards,
Danish Hussain Sabunwala
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Danish Hussain Sabunwala ,
I'm no Scriptrunner expert either, but I think you can achieve what you want without using it !
You could use a simpler validator in your Jira Workflow called "Regular Expression Check". There, you simply have to select your Checkbox field, and enter the correct value the field must have to validate the transition.
Let me know if it helps,
Guilhem
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Guilhem Dupuy ,
If I use 'Regular Expression Check' then I won't be able to provide a custom Validator error message which is also a requirement from the user.
Is there any other approach, please do let me know?
Thanks and regards,
Danish Hussain
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh, I see why you were using Scriptrunner then.
Well as far as I'm aware there is no other way to do it, maybe you can manage to display an error message using Scriptrunner ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Guilhem Dupuy , Yes it will be possible by using Scriptrunner Validators. But still not able to understand the above error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Danish Hussain Sabunwala as I said I'm no Scriptrunner expert I can't really help you with the code unfortunately I was just proposing a work-around :/
The column 24 seems to point to the "." character, but I don't understand why either :/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your time and response.
It is appreciated a lot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks mate ! I hope you'll find an answer to your mater.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!
Join an Atlassian Community Event!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.