
I have a formula where a colon is set if there is none. This should then be patched into the dataverse. But now I want to catch errors such as only numbers can be entered and then only permissible hours and minutes. eg 23:59 or 2359 should be the highest possible number.
If(
Len(inpOrderTimeMonday.Text) > 2 && !(":" in inpOrderTimeMonday.Text),
UpdateContext(
{
locVarColonCheckGalleryMo: If(
Len(inpOrderTimeMonday.Text) = 3,
Left(
inpOrderTimeMonday.Text,
1
) & ":" & Right(
inpOrderTimeMonday.Text,
2
),
Left(
inpOrderTimeMonday.Text,
Len(inpOrderTimeMonday.Text) - 2
) & ":" & Right(
inpOrderTimeMonday.Text,
2
)
)
}
),
UpdateContext({locVarColonCheckGalleryMo: inpOrderTimeMonday.Text})
;
Reset(inpOrderTimeMonday);
);
Patch(
ServiceCapture,
Defaults(servicecapture),
{
Date: DateValue(lblDateMonday.Text, "en"),
Hours: cmpDateTimeFunctions_1.FormatHoursAsMinutes(locVarColonCheckGalleryMo),
Note: inpNoteMonday.Text
}
);
Hi @alt88 ,
I would offer you a better approach to achieve this goal. Please set below formula OnChange of the Text Input box:
If(
IsMatch(
Self.Text,
"^(?:\d|[01]\d|2[0-3]):[0-5]\d$",
MatchOptions.Complete
) || IsMatch(
Self.Text,
"^(?:\d|[01]\d|2[0-3])[0-5]\d$",
MatchOptions.Complete
),
If(
Len(inpOrderTimeMonday.Text) > 2 && !(":" in inpOrderTimeMonday.Text),
UpdateContext(
{
locVarColonCheckGalleryMo: If(
Len(inpOrderTimeMonday.Text) = 3,
Left(
inpOrderTimeMonday.Text,
1
) & ":" & Right(
inpOrderTimeMonday.Text,
2
),
Left(
inpOrderTimeMonday.Text,
Len(inpOrderTimeMonday.Text) - 2
) & ":" & Right(
inpOrderTimeMonday.Text,
2
)
)
}
),
UpdateContext({locVarColonCheckGalleryMo: inpOrderTimeMonday.Text});
Reset(inpOrderTimeMonday);
),
Notify("you must enter a valid time format value");
Reset(inpOrderTimeMonday)
)
So users need to type in a valid hh:mm or h:mm time format value otherwise the textinput box will reset and notify an error message.
Best regards,