Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

I am using the scripted Validator in my workflow where i want to make  a field mandatory.

Priyanka khare
Contributor
October 8, 2020

Hello,

 

I am using the scripted Validator in my workflow where i want to make  a field mandatory. We dont have JSU and are using script runner to achieve this. The URL field "Architecture  Vision " needs to be mandatory and i am using the below code-11.PNG 12.PNG

 

While transitioning even I put the correct URl, the transition does not work still-

 

1 answer

1 accepted

0 votes
Answer accepted
Vikrant Yadav
Community Champion
October 8, 2020

Hi @Priyanka khare You have to use Behavior to achieve this in ScriptRunner.Select transition in behaviour 

 

https://scriptrunner.adaptavist.com/4.3.5/jira/recipes/behaviours/field-required-on-transition.html

Vikrant Yadav
Community Champion
October 8, 2020

@Priyanka khare  you can use Regex validator if you add validator in Workflow. For this you have to scripted validator use this code :- cfValues['Field Name'] ==~ /\d{4}\-\w{8}/ ->

Select Regex code in which field should not be empty ;- [\S\s]+[\S]+

Priyanka khare
Contributor
October 8, 2020

Hello @Vikrant Yadav 

The field is an URL field. Will this code work on URL field too? 

and can u confirm the code here-

 cfValues['URL Field Name'] ==~ /\d{4}\-\w{8}/ ->

 

Regards

Priyanka Khare

Vikrant Yadav
Community Champion
October 8, 2020

Hi @Priyanka khare  Use the below scripted validator to validate URL

cfValues['Field Name] ==~ /^((https?:\/\/|(ftp:\/\/)).*|(.*\.[^\.]{2,6})(\/.*)?)(\:.*)?$/  ( not allow other than URL)

or 

cfValues['Field Name] ==~ /^[\S\s]+[\S]+/   ( not allow empty string)

 

if you want change the code you can change it as per your need.

Priyanka khare
Contributor
October 8, 2020

Hello @Vikrant Yadav 

It worked like a charm. Can you also give me the Scripted validator for Multi select JIRA field? We dont have JSU and hence its bit of a challenge to sort the syntax for fields.

 

Awaiting your response.

Thanks in advance.

 

Regards

Priyanka

Vikrant Yadav
Community Champion
October 8, 2020

Great :) please accept the answer as it's solved. 

Vikrant Yadav
Community Champion
October 8, 2020

for multi select it works like this :- cfValues['My Multi Select']*.value.contains("Some value")

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, rovo agent workshop, rovo workshop series, build rovo agent, atlassian intelligence, ai agents, rovo in action, automation agents, ai for teams, atlassian learning, rovo development, agent building tutorial

[Workshop Series] Let's build a Rovo Agent

AI-curious? This series walks you through building Rovo Agents step by step, no matter your experience level. Multiple workshops available throughout October and November!

Register now
AUG Leaders

Upcoming Jira Events