"Return False" resulting java.lang.NumberFormatException: For input string: "false”
My customer is writing a script to access value of timestamp so that once timestamp attribute does not contain value, it will write data otherwise it will not take any action. Therefore customer used "return false".
Script works fine when attribute is empty - inputs timestamp value, however when the attribute already contain value, it will generate java.lang.NumberFormatException: For input string: "false” in log file.
Could you please refer to below script and advise how script will need to be modified in order to avoid current error?
-------------------
dojo.provide("com.ibm.providers.script.TimeStampTest");
(function() {
dojo.declare("com.ibm.providers.script.TimeStampTest", null, {
getValue: function(attribute, workItem, configuration) {
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date.stamp");
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var WorkItemState = workItem.getValue(WorkItemAttributes.STATE);
if ( WokkItemState == "com.ibm.workflow.state.s4" ) {
var cm_act_start_date= dojo.date.stamp.fromISOString(workItem.getValue("com.ibm.workitem.attribute.cm_act_start_date"));
if (cm_act_start_date == null){
var currentDate = new Date();
var currentDateString= dojo.date.stamp.toISOString(currentDate, {milliseconds:true, zulu:true});
return currentDateString;
} else {
return false;
}
} else {
return false;
}
}
});
})();
-------------------
Script works fine when attribute is empty - inputs timestamp value, however when the attribute already contain value, it will generate java.lang.NumberFormatException: For input string: "false” in log file.
Could you please refer to below script and advise how script will need to be modified in order to avoid current error?
-------------------
dojo.provide("com.ibm.providers.script.TimeStampTest");
(function() {
dojo.declare("com.ibm.providers.script.TimeStampTest", null, {
getValue: function(attribute, workItem, configuration) {
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date.stamp");
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var WorkItemState = workItem.getValue(WorkItemAttributes.STATE);
if ( WokkItemState == "com.ibm.workflow.state.s4" ) {
var cm_act_start_date= dojo.date.stamp.fromISOString(workItem.getValue("com.ibm.workitem.attribute.cm_act_start_date"));
if (cm_act_start_date == null){
var currentDate = new Date();
var currentDateString= dojo.date.stamp.toISOString(currentDate, {milliseconds:true, zulu:true});
return currentDateString;
} else {
return false;
}
} else {
return false;
}
}
});
})();
-------------------
One answer
as you might already know, the value "false" wouldn't match the expected "timestamp" and hence the format error. the "do nothing" part of this script is difficult to achieve as when a script is called it would return something. to nullify the effect, i would attempt to return the read value when there is some value. the number format error wouldn't appear and since the same value is written back, giving a overall effect of no change. hope it helps, I haven't tested this though...