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 Platform Community / Forums / Power Apps / IfError Exception hand...
Power Apps
Answered

IfError Exception handling

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hey guys,

Running into a new problem and I'm not able to fix it.

 

 

IfError(Set(
 setVar;
 Patch(
 CDS_1;
 gallery.Selected;
 {
 Amount: Value(textfield.Text);
 Mail: combobox.Selected.UserPrincipalName; 
 }
 )
 ); Notify("Not a valid value. Please enter a valid value."; NotificationType.Error));

 

 

Following error occurs if I type a comma into the textinput field:

 

An error occurred while validating input parameters: Microsoft.OData.ODataException: Cannot convert the literal '777.677' to the expected type 'Edm.Int32'.---> ...

 

Yes, I know this value with comma isn't valid and can't be converted into an integer value. But how to perform a try and catch in powerapps?

 

As you can see above what I did in the code but it's not working. There's no way to catch the exception and throw the error message.

 

How to achieve it?

 

Thanks so much for helping!

 

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,925 on at

    Can you explain further what you are trying to achieve. Do you want to validate if the Textbox contains number?

     

    Also is your Patch working without the Error code?

    ------------

    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.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hey @eka24,

     


    @eka24 wrote:

    Can you explain further what you are trying to achieve. Do you want to validate if the Textbox contains number?


    I only want that the textfield accepts numbers. No commas, no characters nothing. Only integers.

    But if I type a comma, it's being accepted by the textfield. I don't like it.

     


    @eka24 wrote:

    Also is your Patch working without the Error code?


    Absolutely. Working perfectly without error code.

     

    Thanks so much for your reply.

  • eka24 Profile Picture
    20,925 on at

    The simplest way is to change the format of the Textbox to number. Tha way, anything that is not a number would be rejected.

     

    If you want a notification rather, try;

     

    If(

    !IsMatch(textfield.Text,"[0-9]"), Notify ("Your Text here"), Patch(...........)

    ------------

    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.

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hey @eka24,

     

    Thanks so much for your reply.

     

    This is working for me:

     

     

     

     

    If( !IsMatch(textfield.Text,"\d+"), Notify ("Your Text here"), Patch(...........)

     

     

     

     

    "\d+" -> If you type this, it's working the way it should.

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 494

#2
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#3
11manish Profile Picture

11manish 323

Last 30 days Overall leaderboard