It's all about the answers!

Ask a question

Would like restrict Planned Closure Date should not be lesser than Creation Date

mrp singer (1021315) | asked Jan 16 '13, 12:13 a.m.
Hi Jazzier..

I am using RTC 4.0 and i would like to have validation script for Planned Closure Date should not be lesser than Workitem Creation Date.

For example:  Creation is today " 16-01-2013 ( Time Stamp attribute) and Planned Closure Date is also Mandatory for while saving Workitem. User should get prompt or message notify that , Planned Closure should be greater than equal to Creation Date. But it should not be lesser than Creation Date" ( Planned Closure Date = 16 -01-2013 and above and should not be 15-01-2013)

I am beginner in Dojo / Java, Some can help with scripts. So that i can take forward on this.

Many thanks in advance


One answer

permanent link
Ralph Schoon (63.2k33646) | answered Jan 16 '13, 9:32 a.m.
Have you looked at

There is also an example showing how to use the timestamp date.

I would also recommend to look at the Enactment Workshop. Below is some JavaScript based validator code that works with dates.

 * Licensed Materials - Property of IBM
 * (c) Copyright IBM Corporation 2011. All Rights Reserved.
 * Note to U.S. Government Users Restricted Rights:  
 * Use, duplication or disclosure restricted by GSA ADP Schedule 
 * Contract with IBM Corp. 

dojo.require(""); // To access the work item attributes
dojo.require(""); // To create a status object to return
dojo.require(""); // To create a severity for the status
dojo.require(""); // We need the date class from Dojo to compare two dates
dojo.require(""); // We need the stamp class to work with ISO date strings

(function() {
var Severity =;
var Status =;

var DateValidator = dojo.declare("org.example.DateValidator_28_days_later", null, {

    validate: function(attributeId, workItem, configuration) {
        var severity= "ERROR"; 
        var message= "Date must be at least 28 days from now"; 
       // Work Item new: not initialized - provides todays date. Once created provides the creation date 
        var beginDate ="")); 
        // Get the current attribute's value and make a Date object from it
        console.log("I got: ["+workItem.getValue(attributeId)+"]");
        var endDate=;        
        // Compare the two dates returns negative value due to order
        var compare = -(, beginDate, "day"));
        if (compare>= 28) { // make sure endDate is not earlier than beginDate + 28
            return Status.OK_STATUS;
        } else {
            return new Status(Severity[severity], message + " current value: [" +endDate + "] and difference is " + compare);

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.