I\'m using an Edit Box control to display a date field. When the XPage is saved, I would like to save the date only (now both date and time are being saved). Is there any wa
This code worked for me:
<xp:this.postSaveDocument><![CDATA[#{javascript:
var dt:DateTime = document1.getItemValueDateTime("dateReparatur");
dt.setAnyTime();
currentDocument.getDocument(true).replaceItemValue("dateReparatur", dt);
currentDocument.getDocument(true).save()
}]]></xp:this.postSaveDocument>

It does work at postSaveDocument event only. If you put the same code into querySaveDocument event (without document save() line of course) the date field gets polluted with time after event during saving.
An alternative is to execute computeWithForm at querySaveDocument event:
<xp:this.querySaveDocument><![CDATA[#{javascript:
document1.getDocument(true).computeWithForm(true, true)
}]]></xp:this.querySaveDocument>
You'd have to add an Input Translation formula to date field(s) in your form:
@Date(@ThisValue)
computeWithForm has a poor performance and causes sometimes side effects on field values though but might be a good solution especially if you have a lot of such date-only-fields.
getDateOnly() returns a string. Try this:
dt.setAnyTime();
currentDocument.replaceItemValue("dateReparatur", dt);
Or you may have to get the Document:
currentDocument.getDocument(true).replaceItemValue("dateReparatur", dt);