Jump to content

Edit time portion of DateTime on a Details page


Recommended Posts

Hello. I see how I can create separate Date Time fields on a Submission form. This is working but if I want to return to that record to edit the Time portion of the Date this method does not seem to work. Is there a way to adapt this for Updating, or is there some other way I can see my Date with Time to allow an edit? Currently the only way I am able to view the full Date and Time in a single field on a Details page is by making it Display Only and setting the formatting. I have played around with localization but it still seems that I cannot see the Date and Time together in an editable Text field on my Details page...

Link to comment
Share on other sites

Hi @ray,

Feel free to create a Footer on the Details page and put the code below there to put each part of the Data/Time field in the separate Text field:

<script>
document.addEventListener("DataPageReady", function() {

    var str = document.getElementById("EditRecordDate_Field");
    let monthField = document.getElementById("cbParamVirtual1"),
        dayField = document.getElementById("cbParamVirtual2"),
        yearField = document.getElementById("cbParamVirtual3"),
        hourField = document.getElementById("cbParamVirtual4"),
        minuteField = document.getElementById("cbParamVirtual5"),
        secondField = document.getElementById("cbParamVirtual6"),
        strArr = str.value.split(" "),
        date = strArr[0],
        time = strArr[1] || '00:00:00';

    var month = date.split("/")[0],
        day = date.split("/")[1],
        year = date.split("/")[2],
        hour = time.split(":")[0],
        minute = time.split(":")[1],
        second = time.split(":")[2];

    monthField.value = month;
    dayField.value = day;
    yearField.value = year;
    hourField.value = hour;
    minuteField.value = minute;
    secondField.value = second;

    document.addEventListener("BeforeFormSubmit", function() {
        str.value = ' ';
        str.value = monthField.value + '/' + dayField.value + '/' + yearField.value + ' ' + hourField.value + ':' + minuteField.value + ':' + secondField.value;
    });
});
</script>

where EditRecordDate_Field is an ID of the Date/Time field and cbParamVirtual1 is an ID of the virtual field for displaying a separate part of the Date/Time field.

For a better understanding of how it works, please see the attached screenshots: 


image.thumb.png.2763a4b477f0d152c9742ef88dec603b.png

 

Search and Report Wizard - Configure Details Page Fields:

image.thumb.png.5d52a83c7efb02123ac017f7d88f5a78.png

Link to comment
Share on other sites

  • 3 years later...
  • 6 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...