Reputation:
I'm trying to use SSJS to update a date field. This works fine if the option "Use date/time picker pop-up" is not selected. However if this option is checked, the update does not work. Can anyone explain why this is? Here is my code:
<xp:panel rendered="true">
<xp:button value="Set Date Value" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="DateField">
<xp:this.action><![CDATA[#{javascript:document1.setValue("DateField","01.01.1970");}]]></xp:this.action>
</xp:eventHandler></xp:button>   
<xp:inputText id="DateField" value="#{document1.DateField}">
<xp:this.converter>
<xp:convertDateTime type="date"></xp:convertDateTime>
</xp:this.converter>
<xp:dateTimeHelper></xp:dateTimeHelper>
</xp:inputText>
</xp:panel>
Upvotes: 0
Views: 1114
Reputation: 3484
To be able to set a date field you need to set it using a correct date format
document1.setValue("DateField","01.01.1970")
The Date format needs to be java.util.Date so try this
document1.setValue("DateField",new Date("01.01.1970"))
But I would suggest doing it this way because then you code isn't bound to that the server is using that specific locale settings.
var date=new Date();
date.setFullYear(1970)
date.setMonth(0) //remember months starts with 0
date.setDate(1)
document1.setValue("DateField",date)
One thing is that I haven't got this to work when running in a Notes client, but that might be a bug.
Upvotes: 7