Issue with Clearing Date/Time Component in UiPath Forms via Button Click

Hi everyone,

I’m currently working on a UiPath Form where I use a Date/Time component and a Button. The Date/Time field is usually pre-filled with a date, but I want to allow users to clear this field by clicking a button. Here’s what I’ve tried so far:
A date input field labeled "Datum Frist" with the date "02.10.2024" entered and a button labeled "remove Date." (Captioned by AI)

  1. Component Setup:

    • The Date/Time component has the key frist.
    • The Button has the key fristEntfernen and is set to trigger a Click action.
  2. Custom Code:
    In the Custom Code section, I added the following JavaScript to clear the Date/Time field when the button is clicked:

    form.getComponent('fristEntfernen').on('click', function() {
        form.getComponent('frist').setValue(null);
    });
    

    However, when I click the button, nothing happens, and the Date/Time field remains unchanged.

  3. Other Observations:

    • I have another JavaScript block elsewhere in my form that correctly formats a date and returns it as part of a string. This part works fine.
    • I’ve checked the keys for both components, and they seem to be correct.

Question:

How can I make sure that the Date/Time component gets cleared when the button is clicked? Is there something I’m missing in the configuration or the JavaScript logic?

Thanks in advance for any help!

@power

the only change is using ‘’ instead of null

form.getComponent('frist').setValue('');

Also in custom code just the above line is enough

Hope this helps

cheers

2 Likes

Thank you for the suggestion! You were absolutely right — the key to solving this issue was using '' instead of null to clear the Date/Time field.

The final solution was as simple as this:

I added this line in the Display/Update Data Logic section, and it worked perfectly.

Additionally, I realized that my issue may have been related to the Legacy interface in UiPath Forms, which could explain why I had a different view than yours.

Thanks again for the help!

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.