Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

End date should be greater than start date

 Hi All,

I have created two custom attributes start date and end date. When i create WI My end date should be greater than Start date.

for eg start date - 15/02/2013    then end date - 16/02/2013  

If my end date is less then 15/02/2013 then i should get error message.

How can i do this??

Regards,
Amit

0 votes



2 answers

Permanent link
Hello Amit,
check the date validator sample here:
https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_Based_Validation

Thanks.
Eric.

2 votes

Comments

Hey Eric,


Thanks for your reply.


i went through that links and tried to resolve it , but i didn't work for me as i am new to javascript

Do you have working script for the same?
it will be very helpfull for me.

regards,
amit

Hello Amit,
sample js below (no guarantee it works - this is just a sample for which you'll have to fill the blanks, adapt..)
However, hope it will help.
Thanks.
Eric.


Permanent link

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

    validate: function(attributeId, workItem, configuration) {
        var severity = "ERROR";
        var message = "your error msg here";

        var wi_type = workItem.getValue(WorkItemAttributes.TYPE);
        if (wi_type != "your work item type here") {
                // we may want to restrict the validation to a given type only
                return Status.OK_STATUS;
        }

        var beginDate = dojo.date.stamp.fromISOString(workItem.getValue("your begin date"));
        var endDate= dojo.date.stamp.fromISOString(workItem.getValue("your end date"));
               
        // Compare the two dates and make sure endDate is not earlier than beginDate
        if (dojo.date.compare(endDate, beginDate) >= 0) {
            return Status.OK_STATUS;
        }else if((beginDate == null) && (endDate == null)) {
            return Status.OK_STATUS;
        }else if((beginDate != null) && (endDate == null)) {
            return Status.OK_STATUS;
        }else {
            return new Status(Severity[severity], message);
        }
    }
});
})();

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 152

Question asked: Feb 04 '13, 9:06 a.m.

Question was seen: 9,502 times

Last updated: Apr 02 '13, 4:01 a.m.

Confirmation Cancel Confirm