Create a workflow validator for Date

Jason Galea
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.
July 20, 2018

Hi,

I have a Field on issue creation named Start Date. I would like to create a validator that only allows dates to be set not earlier than the 1st day of the current month. 

Can I please get some examples?

Cheers,
Jason

2 answers

1 vote
Alexey Matveev
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.
July 20, 2018

Hello,

Try like this:

 

import com.atlassian.jira.component.ComponentAccessor
import java.util.Calendar

def issue = ComponentAccessor.getIssueManager().getIssueObject("IM-587166")
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Start Date")
Calendar c = Calendar.getInstance(); // this takes current date
c.set(Calendar.DAY_OF_MONTH, 1);
if (issue.getCutomFieldValue(cf) < c.getTime()) {
return true
}
return false
0 votes
Robert Dzido
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.
July 23, 2018

Hi @Jason Galea,

 

You can also use Workflow PowerBox add-on to solve it.

There is 2 features you can use:

- Use "Run Condition as a Validator"

- Inside the validator use "Universal Date/Time Condition".

Claudio Casiello January 24, 2020

thank you it worked!!

Suggest an answer

Log in or Sign up to answer