Hello All,
Before submitting a form I am trying to set a time condition that the end time of the task is not before the start time. I can verify that the DateDiff() formula below does produce a negative value if endTime < startTime. However when the logic evaluates to true, the form is still submitted.
Here's the code:
If(
DateDiff(startTime, endTime, Seconds) < 0,
LabelForTimeError.Text = "TIME IS WRONG!",
SubmitForm(SweepForm)
);
Your help is greatly appreciated!
Solved! Go to Solution.
It was a bug in my code. My understanding of the scoping in PowerApps is not there. I left a Navigate function outside the If statement, and no matter what happened in the conditional, the Navigate function ultimately is called.
A little clarification, is starttime and endtime variables or DatePicker or from a column. If variable, can you show the formula
------------
If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
startTime and endTime are local variables defined by Now() in their respective buttons.
UpdateContext({endTime: Now()})
It was a bug in my code. My understanding of the scoping in PowerApps is not there. I left a Navigate function outside the If statement, and no matter what happened in the conditional, the Navigate function ultimately is called.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
256 | |
126 | |
85 | |
85 | |
68 |