Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Validate checkbox custom field with Scriptrunner Edited

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.

Error Validator.PNG

Could you please help me with the solution?

Thanks and Regards

Danish Hussain

 

2 answers

1 accepted

3 votes
Answer accepted

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

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

Hello @Kristian Walker _Adaptavist_ ,

Thanks a lot for your help. The following code provided the answer I was looking for.

Regards,

Danish Hussain Sabunwala 

0 votes
Guilhem Dupuy Community Leader May 20, 2021

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

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

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 ?

@Guilhem Dupuy , Yes it will be possible by using Scriptrunner Validators. But still not able to understand the above error. 

Guilhem Dupuy Community Leader May 20, 2021

@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 :/ 

@Guilhem Dupuy ,

Thank you for your time and response.
It is appreciated a lot.

Like Guilhem Dupuy likes this
Guilhem Dupuy Community Leader May 20, 2021

Thanks mate ! I hope you'll find an answer to your mater.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

203 views 6 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you