Why does RTC correctly add error indicator only first time a validator script is invoked for same field.
Below is the code for the validator script to check that user does not select a date past today. If today is 02/16/2015, and I select 02/19/2015 for date, the error indicator icon displays on the selection box, as it should. If I then select another past date, say 02/20/2015, the error indicator goes away (though in debug looks like it errored). The error indicator icon seems to toggle on and off for every selection there after, whether past or not. The server side validator catches the past date even though the error indicator icon has disappeared, so that's good. Anything I'm doing wrong or do I need to open a PMR? I'm on 5.02 server and Eclipse client.
dojo.provide("com.impediment.Invoice1DateNotPastToday");
dojo.require("com.ibm.team.workitem.api.common.Severity"); dojo.require("com.ibm.team.workitem.api.common.Status"); (function() { var Severity = com.ibm.team.workitem.api.common.Severity; var Status = com.ibm.team.workitem.api.common.Status; dojo.declare("com.impediment.Invoice1DateNotPastToday", null, { validate: function(attributeId, workItem, configuration) { var I1Date = workItem.getValue("InvoiceDate"); var Today = new Date(); var I1Date = new Date(I1Date); if ( (I1Date == null) || (I1Date <= Today) ) { return Status.OK_STATUS; } else { return new Status(Severity["ERROR"], "Invoice date cannot be past today."); } } }); })(); |
One answer
Ralph Schoon (63.5k●3●36●46)
| answered Feb 17 '15, 3:45 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Feb 17 '15, 3:47 a.m.
I would assume, if you would debug your script e.g. like https://jazz.net/library/article/1360 you will find it errors and some of your assumptions are wrong.
I'd suggest to carefully read how attribute customization works, and search the internet how you can compare dates. I believe the code below works. Just using (I1Date <= Today) does not cut it, I believe. See here: http://stackoverflow.com/questions/492994/compare-dates-with-javascript /******************************************************************************* * 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.provide("org.example.DateValidator"); dojo.require("com.ibm.team.workitem.api.common.Severity"); dojo.require("com.ibm.team.workitem.api.common.Status"); dojo.require("dojo.date"); // We need the date class from Dojo to compare two dates dojo.require("dojo.date.stamp"); // We need the stamp class to work with ISO date strings /* * * You need to configure this script in the Process Configuration Source: * |
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.