Reference a saved Filter in a Workflow transition

Zalesak_ Stacy M February 27, 2025

Hello.  I need to add a validator to an issue workflow that prevents a transition  if a custom field "Start Date" is within a given range.  The complexity comes in since this date range changes month-to-month.  We'd like to create a saved filter that can be modified each month by a non-jira-admin (release manager) but that would be used to allow / restrict issue transition based on this filter.  Any ideas how to do this?

Example

Issue ABC  has start date of Feb 26

Issue DEF has start date of Feb 28.

Saved Filter 12345 = Start Date < 2025-02-28 and Start Date > 2025-03-01

This month, we're restricting issues from deploying the last 2 days of the month (Feb 27, 28).  The range could change next month to be the last 3 or even 4 days (its decided that month)  

The workflow would reference saved filter 12345 and prevent issues from transitioning to "Ready to Deploy" for issue DEF but allow for Issue ABC

Any creative ideas?

3 answers

1 accepted

0 votes
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 27, 2025

Hi @Zalesak_ Stacy M 

unfortunately, with JMWE and ScriptRunner, Validators are restricted to using Atlassian's "Jira Expressions" language, which cannot run JQL searches (not to mention saved searches).

The solution would be to develop your own Forge app, since Forge apps can implement a Validator that has full access to the Jira REST API (which allows access to saved searches).

Zalesak_ Stacy M February 27, 2025

Thank you!

0 votes
Maciej Dudziak _Forgappify_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 27, 2025

Hi @Zalesak_ Stacy M 

I may have a solution for you, but it will require setting a project property.

As you already now, using a filter is not an option, but, if you have another way to pass a variable (e.g. daysBeforeEndOfMonth) to validator, then it is doable. 

You could use project properties, which can be set using REST API or with tools like Entity Property Tool for Jira (from Atlassian Labs)

So let assume you were able to set this property daysBeforeEndOfMonth = 4, and you would update this property once a month

Then you can create Jira Expression based validator, and use following script:

let now = new CalendarDate();
let endOfMonth = now.plusMonths(1).minusDays(now.getDate());

let daysBeforeEndOfMonth = (new Project("YOUR_PROJECT_KEY")).properties["daysBeforeEndOfMonth"];

issue.customfield_10015 != null && new CalendarDate(issue.customfield_10015) <= endOfMonth.minusDays(daysBeforeEndOfMonth)

where customfield_10015 is the id of you custom field.

The last line says that, Start Date must be set and it must be before end of the month, minus yours number of days

I am assuming you have script runner, but if you don't my team developed Jira Expression Validator, which is part of Workflow Building Blocks for Jira app. (I am from Forgappify, the vendor of the app)

That was quite a challenge to figure out. I hope it will work for you.

Cheers

 

0 votes
Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 27, 2025

Hi @Zalesak_ Stacy M 

This can't be done ootb, you will need a marketplace app that provides extra workflow options.

Apps as an example:

  • JMWE
  • JSU
  • JWT
  • Power Scripts
  • Scriptrunner
  • etc
Zalesak_ Stacy M February 27, 2025

Thanks. Yes, we have Scriptrunner and JMWE, but I dont see any options there either.  Ideas on a script using scriptrunner or what validator should i use for JMWE?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
ENTERPRISE
TAGS
AUG Leaders

Atlassian Community Events