I have an input field to record hours. In the onchange I have a formula that checks if the input has colons, otherwise it adds some. And then patches it to the database. Now I would like to catch error cases. For example I want that only numbers are possible and no letters. The whole thing should be caught with an error case. I have tried different approaches which unfortunately did not work. I don't know if I should catch it in the onchange and if so if it is triggered in the patch or in the colon check. The formula in onchange is as follows:
If(
Len(inpAuftragszeit.Text) > 2 && !(":" in inpAuftragszeit.Text),
UpdateContext(
{
locVarColonCheckShowDetails: If(
Len(inpAuftragszeit.Text) = 3,
Left(
inpAuftragszeit.Text,
1
) & ":" & Right(
inpAuftragszeit.Text,
2
),
Left(
inpAuftragszeit.Text,
Len(inpAuftragszeit.Text) - 2
) & ":" & Right(
inpAuftragszeit.Text,
2
)
)
}
),
UpdateContext({locVarColonCheckShowDetails: inpAuftragszeit.Text})
;
Reset(inpAuftragszeit);
);
Patch(
Leistungserfassung,
Defaults(Leistungserfassung),
{
Datum: DateValue(locVarDate, "de"),
Stunden: cmpDateTimeFunctions_1.FormatHoursAsMinutes(locVarColonCheckShowDetails),
Hinweis: inpHinweis.Text
}
);