Actions for "Save" Button

When I click the "Save" button in the Mobile Application I created, if the time is between 09:00 and 13:00 during the day, it should save, otherwise it should give a warning saying "Form is closed for recording". Do I need to define an Actions for the "Save" Button? The method below did not work. The form continues to receive registration. How can we do this?

Behavior

Only if this condition is true: AND(
TIME(TIMENOW()) >= "09:00:00",
TIME(TIMENOW()) <= "13:00:00"
)



il_han_0-1739622429787.png

Don't mind the date on the picture, I corrected it.

Solved Solved
0 10 220
2 ACCEPTED SOLUTIONS

Hey @il_han

You can prevent users from submitting a form between 9 AM and 1 PM using Valid_If, which blocks the submission and shows a clear error message.

Add a DateTime column (e.g., [FormCheck]) in your table.

Set Initial Value to NOW().
Make it Required so it always records the time.
Hide it with Show_If = FALSE if you don’t want users to see it.
Use Valid_If to block submissions at the wrong time

OR(
HOUR([_THIS]) < 9,
HOUR([_THIS]) >= 13
)
This allows submission before 9 AM or after 1 PM.
If it’s between 9 AM and 12:59 PM, the form cannot be saved.
In Invalid value error, write: "Form submissions are only allowed outside 9 AM - 1 PM. Please try later."
In [FormCheck], enable "Reset on edit", so NOW() refreshes when users edit the form.
If a user tries to save a form between 9 AM - 1 PM, AppSheet prevents submission and displays your message. Simple and effective !

Jee

View solution in original post

Hey @il_han 

If you want a column to reset automatically when another field in the same row is edited, just check "Reset on edit?".

In your case, you should enable "Reset on edit?" on the [FormCheck] column so that it updates the timestamp when the form is submitted. This ensures that the time is correctly checked at submission instead of staying stuck on the value from when the form was first opened.

You’ll find this option under Data > Columns > FormCheck in AppSheet.

Hope that helps!

Jee

View solution in original post

10 REPLIES 10

Hey @il_han 

You don’t need an action for this, just use Valid_If or Form Save Condition. Try this in Only if this condition is true:

AND(
  TIME(TIMENOW()) >= "09:00:00",
  TIME(TIMENOW()) <= "13:00:00"
)

But the issue might be that TIMENOW() updates only on sync, so try NOW() instead:

AND(
  TIME(NOW()) >= "09:00:00",
  TIME(NOW()) <= "13:00:00"
)

If the form is still saving outside those hours, make sure you’re applying the condition in Behavior > Form Save Condition, not just somewhere else. Also, check if your device’s time zone is synced properly with AppSheet!

Jee

Using Valid if on a column in the form to enforce the submission time restrictions is an excellent suggestion! Consider also using a custom Invalid value error message to remind the user of the time restrictions.

Steve_0-1739634041695.png

There's no such thing as "Form Save Condition".

Trying to enforce the restrictions using the Form Saved event action won't work: by the time the Form Saved action is performed, the row is already saved. I suppose you could use the action to delete the newly-added row...

"TIMENOW() updates only on sync" is inaccurate. In a form, both TIMENOW() and NOW() provide the time when the expression is evaluated, which is typically when the form is first opened. Neither continuously updates to the current time while waiting for the form to be submitted.

TIMENOW() and TIME(NOW()) are exactly the same.

I have a Valid if condition for each row but I use it for a different process.

I run the following condition for each row. I guess I need to combine the Time constraint with the formula below for each row. Is that correct?


IF(
ISNOTBLANK(LOOKUP("MLR100", "Max.Ürün", "Ürün Adı", "Max Miktarlar")),
[MLR100] <= LOOKUP("MLR100", "Max.Ürün", "Ürün Adı", "Max Miktarlar"),
TRUE
)

 

il_han_0-1740050292387.png

il_han_1-1740050319569.png

 

Hey @il_han

You can prevent users from submitting a form between 9 AM and 1 PM using Valid_If, which blocks the submission and shows a clear error message.

Add a DateTime column (e.g., [FormCheck]) in your table.

Set Initial Value to NOW().
Make it Required so it always records the time.
Hide it with Show_If = FALSE if you don’t want users to see it.
Use Valid_If to block submissions at the wrong time

OR(
HOUR([_THIS]) < 9,
HOUR([_THIS]) >= 13
)
This allows submission before 9 AM or after 1 PM.
If it’s between 9 AM and 12:59 PM, the form cannot be saved.
In Invalid value error, write: "Form submissions are only allowed outside 9 AM - 1 PM. Please try later."
In [FormCheck], enable "Reset on edit", so NOW() refreshes when users edit the form.
If a user tries to save a form between 9 AM - 1 PM, AppSheet prevents submission and displays your message. Simple and effective !

Jee

No, the Valid if of the many Number columns you have would not change. Instead, I was thinking you could set or adjust the Valid if for this column:

Steve_0-1740065453975.png

Even if the user can't edit the column value, the column can have a Valid if expression and it will be enforced if the column is displayed in the form.

My problem is solved, thanks Jee, thanks Steve.

 

il_han_1-1740066694398.png

 

 

Nice!

I have one more question. Some users turn on the screen before 13:00. For example, at 12:50. He left this screen open and sent data after 13:00. Will this rule we set read my current time or the time that appears on the screen? I didn't have the opportunity to test.

Hey @il_han 

If you want a column to reset automatically when another field in the same row is edited, just check "Reset on edit?".

In your case, you should enable "Reset on edit?" on the [FormCheck] column so that it updates the timestamp when the form is submitted. This ensures that the time is correctly checked at submission instead of staying stuck on the value from when the form was first opened.

You’ll find this option under Data > Columns > FormCheck in AppSheet.

Hope that helps!

Jee

güzel fikirler edindim.