We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Restrict user selecting past date and time in catalog.

WaseemM
Tera Expert

I have a code block with restricts the user to select past dates, but I'm not able to restrict the past time. For example, my current date and time is 2025-12-11 01:30:00.  I want the user to be restricted to pick the time of 2025-12-11 01:25:00, which is the same day but a past time.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '')
        return;

    var value = g_form.getValue('snapshot_creation_time');
    if (!value)
        return;

    // Convert the snapshot_creation_time to a time object
    var snapshotTime = new Date(value);
    var currentTime = new Date();

    // check if snapshot creation time must be in future
    if (snapshotTime <= currentTime) {
        g_form.showFieldMsg('snapshot_creation_time', 'Snapshot creation time must be in the future.', 'error');
        g_form.setValue('snapshot_creation_time', '');
    }
}

 

1 ACCEPTED SOLUTION

I didn't know that we could do this with UI Policy.

I just made it as shown below according to my requirements. Thanks!

 

UI Action.pngUI Policy.png

View solution in original post

5 REPLIES 5

It works for the date, it again fails when I choose a future time on the same day.