How to compare two Date attributes in a script-based validator?
![]()
Arjun Pande (3●6●14)
| asked Apr 13 '16, 2:06 a.m.
converted to question Apr 14 '16, 1:04 a.m. by Donald Nong (14.5k●4●14) Hi Ralph,
I need to write a dojo script where I can compare 2 dates, one is IBM out of the box field due date and other is system current date. I am writing a validator script where users will not be allowed to enter the Due date < Current Date. Due Date can be equal to or greater than current date. Below is the dojo script for the same.
dojo.provide("DueDateValidation");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); // To access the work item attributes
var DateValidator = dojo.declare("DueDateValidation", null, {
validate: function(attributeId, workItem, configuration) {
I am using formal process management template and the CLM version is 6.0. Please let me know your thoughts on this. Any help is appreciated. Thanks.
|
3 answers
![]()
The template I am using is Formal Process Management Template and the RTC version is 6.0. So the id's of the due date comes from that template.
|
![]()
Ralph Schoon (62.3k●3●36●43)
| answered Apr 14 '16, 2:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
See https://jazz.net/forum/questions/220004/how-the-below-code-works-for-date-validation/220007
|
![]()
Ralph Schoon (62.3k●3●36●43)
| answered Apr 14 '16, 2:31 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I had to ban one answer as that had only philosophical content and a link to a resort page.
|
Comments
Posting a question as an answer to in an old post does not get you anywhere. I've converted it to a question now.
Your script is quite messy, to say the least. Why do you convert a String to a Date, and then to a String, and finally compare two String values? What is the purpose of the variables PHED and StringPHED? You did not say whether the script works for you or not - have you tried it?
Posting on an old question is not a good idea and trying to direct questions in specific users directions neither.