End date should be greater than start date
Amit Girme (11●3●20●27)
| asked Feb 04 '13, 9:06 a.m.
edited Apr 02 '13, 4:01 a.m. by Ralph Schoon (63.3k●3●36●46)
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
|
2 answers
Hello Amit,
check the date validator sample here: https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_Based_Validation Thanks. Eric. Comments
Amit Girme
commented Feb 04 '13, 9:33 a.m.
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,
|
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); } } }); })(); |
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.