Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

How to write a script to validate a customfield (for scriptrunner)

Edited

There is a custom field "Email";

I need a validation script to check if any other issue in the same project has the same value for the custom field "Email".

I'd like to run the script on "ScriptRunner" as displayed below.

Following doesn't work:

count(issuesFromJQL("project = %{issue.project.key} AND 'Email' = issue.email ")) == 0

This one doesn't work as well:

issuesFromJQL("project = %{issue.project.key} AND 'Email' = issue.email ").count == 0

I appreciate your support on this.

Screen Shot 2021-03-14 at 21.04.39.png

 

 

2 answers

1 accepted

1 vote
Answer accepted

Hi @Zeyd Gulesin 

Thank you for your question.

I can confirm that the ScriptRunner for Jira Cloud plugin provides workflow Validators using the Jira Expression Framework as documented in the Atlassian API documentation page located here or in the documentation page located here which explains how to add in a new validator to your workflow.

We can confirm that when viewing the Jira Expression Framework API documentation page linked above you can navigate to the Context variables section which shows what variables are provided by this framework that can be used to create the expression.

If you then click on one of the variables it will show all the properties that can be called on the variable for the expression such as for the issue variable as shown here and you will be able to check this to see if Atlassian provides a variable that contains the item you want to check against.

We can also confirm we have some examples of validators that can be used as a reference guide in the page located hereas well as in the documentation page located here.

We would recommend using these documentation pages linked above as a reference guide to help to create the validator expression that you require.

Finally, I can confirm that I have checked the Jira Expressions documentation pages linked above and can confirm that Atlassian does not provide any way to search for a set of issues using JQL which means that you will be unable to create a scripted validator that is based on a JQL search inside of Jira Cloud.

I hope this information helps.

Kind Regards

Kate

Thank you for the detailed information Kate, I appreciate.

I think this feature should be added to Jira Expressions. 

Kind regards. 

Zeyd

Hi @Zeyd Gulesin 

Thank you for your suggestion. We appreciate your feedback.

Kind Regards

Kate

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

101 views 1 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