cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

IfError Exception handling

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

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.

View solution in original post

4 REPLIES 4
eka24
Super User
Super User

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.

Anonymous
Not applicable

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.

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.

Anonymous
Not applicable

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.

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (4,084)