Preventing Form Submission Based on Conditional Logic

I want to prevent users from submitting the form when the “Date de résolution” field is filled but the “Commentaires de résolution” field is empty.

Currently, I’m having trouble implementing an onsubmit action that displays an error message while keeping the edit screen open for users to make corrections. To address this, I’ve created a button (RUN ACTION) linked to a custom action.

However, I’ve encountered a challenge: the “Commentaires de résolution” field does not update in real-time until the user submits the form, which means the action cannot read the current data the user has entered.

In this screenshot, I clicked the button to run the action, and the behavior is as expected:

In this screenshot, the behavior is not as expected:

How can I make the custom action check the current value of the “Commentaires de résolution” text field (which hasn’t been saved to the database yet) from the edit screen?

Funny fact: If I add a “set column value” action in the custom action to insert random text into the “Commentaires de résolution,” it successfully updates the front text field, even though it doesn’t reflect in the backend (which is expected).

I assume Date de résolution is not a required field and Commentaires de résolution is required only when the date is filled?

What I would do is create two Commentaires de résolution text boxes. One with the required flag checked and one without. Then show the non-required text entry when the date is empty and the “requred” text entry when the date is filled. Text boxes with the “required” flag checked will not apply if they are not visible.

2 Likes

You are awesome, thanks!

1 Like

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