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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Create a workflow validator for Date

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

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

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".

thank you it worked!!

Suggest an answer

Log in or Sign up to answer
TAGS

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