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?
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This can't be done ootb, you will need a marketplace app that provides extra workflow options.
Apps as an example:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
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.