This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.

Aug 23, 2016, 11:39 AM
94 Posts

My date field format changes automatically upon file upload / refresh. How can I fix that?

  • Category: Debugging
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags:
  • Replies: 2

I have a panel with a date field and an upload control.  The Date field is formatted as MMM d, yyyy.  When I pick a date, it displays correctly.  However, upon selecting a file in the upload control, the date field automatically changes to yyyy-mm-dd format and the date picker button disappears and I get an "invalid date" error.  The upload is causing the issue.

If I manually change the date again to it's intended format, I can refresh the panel (which retrieves the date picker button again) and am able to save the document.

If I select a date and manually refresh the panel, the date format will not change.  It only auto changes when a file is selected in the upload control.

I originally had the date format using "Default" but have since changed it to "Custom" for MMM d, yyyy format, but there was no change, it still reformats automatically with a file selection.

How do I get around this problem?

Aug 25, 2016, 12:38 AM
453 Posts
Would need to see the source code.

Can you create a simple page with the date field and upload control and see if you can make it do the same thing. I'm guessing but I would think that there might be something elsewhere on the page that is getting in the way.  I had something similar the other day and I eventually stripped the page down and isolated the problem then rebuilt the functional page. The solution in my case was pretty simple. I have an axiom 'a bug that is easy to find is hard to fix, a bug that is hard to find is easy to fix---- all bugs take the same time to fix!

Aug 25, 2016, 9:33 AM
94 Posts
Thank you for the input

Yes, I had to do exactly that, stripped everything out except the date, the upload and a Save button.  I discovered that the document would actually save, and THEN the date would get reformatted.  So, as a workaround, I added code to clear the date field in the oncomplete event of the Save button - and that actually works.  So, not a solution, but a workaround.  (I was able to do that only because the Save performed a partial refresh.  The form actually appears in a dojo dialog panel)

I'm still looking for a solution, because I'm afraid I'll run into this again in the future.

Here's how it looks before Save

and after Save

Here's the xpage code

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp=""><xp:panel id="panelCustPO">
            <xp:dominoDocument var="document3" formName="CustPOTemp" ignoreRequestParams="true">
        <xp:table style="background-color:rgb(242,242,242);border-color:rgb(128,128,128);border-style:solid;border-width:thin">
                <xp:td style="text-align:right">

                    <xp:label value="P.O. Received Date:" id="label101">
                <xp:td style="background-color:rgb(255,255,255)">
                    <xp:inputText id="DateRec" value="#{document3.DateRec}" style="height:20px">
                            <xp:convertDateTime pattern="MMM d, yyyy">
                <xp:td style="text-align:right" valign="top">
                    <xp:label value="P.O. Attachment:" id="label225"
                <xp:td style="background-color:rgb(255,255,255)">
                    <xp:fileUpload id="Attachments"
                        value="#{document3.Attachments}" style="width:99%;height:20px">
                <xp:td colspan="3" style="background-color:rgb(255,255,255);text-align:right;padding-top:10.0px">
                    <xp:button id="button18" value="OK" style="width:80px;margin-bottom:5.0px">
                        <xp:eventHandler event="onclick" submit="true"
                            refreshMode="partial" id="eventHandler55"
                                    <xp:saveDocument var="document3"></xp:saveDocument>
                                        message="save successful">
                            <xp:this.onComplete><![CDATA[//var fld = XSP.getElementById("#{id:DateRec}");
//fld.value = ""]]></xp:this.onComplete>



This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.