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-
While transitioning even I put the correct URl, the transition does not work still-
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
@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]+
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great :) please accept the answer as it's solved.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
for multi select it works like this :- cfValues['My Multi Select']*.value.contains("Some value")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.