Reputation: 2030
In IBM notes I have a Java agent which checks if the field ActualDelivery date is empty or not:
String ActualDeliveryDate = orderRegelDocument.getItemValueString("ActualDeliverydate");
if (ActualDeliveryDate.equals("") ){
But the problem is that this field ActualDeliverydate is set in some documents as a Text field and in some documents as a DateTime field.. So how can I know when it is a text field and then take the string and when to take it as DateTime?
Upvotes: 0
Views: 90
Reputation: 14628
Get the Item instead of the item value.
Item theItem orderRegelDocument.getFirstItem("ActualDeliverydate");
Then check the Item's Type property and do the conversion if necessary:
String ActualDeliveryDate;
if (theItem.getType() == Item.DATETIMES)
{
DateTime dt = theItem.getDateTimeValue();
ActualDeliveryDate = dt.getLocalTime();
}
else
{
ActualDeliveryDate = orderRegelDocument.getItemValueString("ActualDeliverydate");
}
Upvotes: 2
Reputation: 111
Aditionally, you could delete empty DateTime and Number fields from documents. In classic Notes development, a simple @If(@Text(@ThisValue) = ""; @DeleteField; @ThisValue)
in InputValidation
can do the job.
Upvotes: 0
Reputation: 341
I don't use IBM notes, but this should work
Object actualDeliveryDate = orderRegelDocument.getItemValue("ActualDeliverydate");
if(actualDeliveryDate instanceOf String){
//compare with a string
}else if(actualDeliveryDate instanceOf Date){
//do something else
}
I don't know about the actuel object that are used, so just debug it to see it.
Upvotes: -1