web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Catch errors

(0) ShareShare
ReportReport
Posted on by 171

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
 }
);

 

Categories:
I have the same question (0)
  • Ethan_009 Profile Picture
    4,838 Moderator on at

    Hi @alt88 ,

     

    If you merely need to catch errors, your code can be

    IfError(
     Patch(
     Leistungserfassung,
     Defaults(Leistungserfassung),
     {
     Datum: DateValue(locVarDate, "de"),
     Stunden: cmpDateTimeFunctions_1.FormatHoursAsMinutes(locVarColonCheckShowDetails),
     Hinweis: inpHinweis.Text
     }
     );
     ,
     Notify("Error occurred..", NotificationType.Error, 1000);
     false;
     ,
     Notify("Record saved successfully", NotificationType.Success, 1000);
     true;
    )

     

    Coming to your point if you need to ensure numbers instead of alphabets.

    You can set your textbox format to numbers specifically. 

    If you aren't using something as such, you can try to check items before sending Patch request.

    You can check if certain text is number or has alphabets. 1 method is regex

     

    Hope this helps

  • alt88 Profile Picture
    171 on at

    The problem is that I need it to be an input field, since the number being entered is in the format hh:mm. Means an input of 1:00 or 2:00 etc.

  • Ethan_009 Profile Picture
    4,838 Moderator on at

    Understood @alt88 ,

    You can use Regex expression to ensure such format is achieved. 

    Similar Reference Blog

     

    Hope this helps 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#2
11manish Profile Picture

11manish 205 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard