Latest Posts

PowerApps How to check for the error in function


The IsError function in PowerApps is used to determine whether an expression results in an error. This function is useful for error handling and validation, allowing you to create more robust and user-friendly applications by managing potential errors effectively.

PowerApps – IsError() Syntax

 

IsError(Value)

 

  • Value: The expression or value you want to check for errors.

PowerApps – IsError() basic example

To check if a division operation results in an error (e.g., division by zero):

 

IsError(1 / 0)

This returns true because dividing by zero results in an error.

PowerApps – Handle Error in Calculations using IsError()

To handle potential errors in a calculation, such as taking the square root of a negative number:

 

If(IsError(Sqrt(-1)), "Error: Negative number", "Result: " & Sqrt(-1))

This checks if the square root operation results in an error and displays an appropriate message.

PowerApps - Validate User Input using IsError() function

Suppose you have a text input control where users can enter a number, and you want to ensure that it is a valid number before performing calculations:

 

If(IsError(Value(TextInput1.Text)), "Invalid number", "Valid number")

 

This checks if the input can be converted to a number and displays an appropriate message.

PowerApps - Check for Errors in Data Retrieval using IsError()

When retrieving data from a data source, you can check for errors and handle them gracefully. For example, if you are using a LookUp function:

 

Set(LookupResult, LookUp(DataSource, ID = SomeID));

 

If(IsError(LookupResult), Notify("Error retrieving data", NotificationType.Error), DisplayData(LookupResult))

 

This checks if the LookUp function results in an error and displays a notification if an error occurs.

PowerApps – Handle Error in Form Submissions using IsError()

To handle errors that may occur during form submission, you can use the IsError function to check the result of the submission:

 

SubmitForm(Form1);

 

If(IsError(Form1.LastSubmit), Notify("Submission failed", NotificationType.Error), Notify("Submission successful", NotificationType.Success))

 

PowerApps – Check for error in Calculation using IsError

Set the OnSelect property of the button to:

 

Set(Result,

    Switch(

        OperationDropdown.Selected.Value,

        "Add", Value(NumberInput1.Text) + Value(NumberInput2.Text),

        "Subtract", Value(NumberInput1.Text) - Value(NumberInput2.Text),

        "Multiply", Value(NumberInput1.Text) * Value(NumberInput2.Text),

        "Divide", Value(NumberInput1.Text) / Value(NumberInput2.Text),

        "Unknown operation"

    )

);

 

 

If(IsError(Result), Notify("Error in calculation", NotificationType.Error), Set(ResultText, Result))

 

 


We value your Feedback:

Page URL:

Name:

Email:


Suggestion:

© 2024 Code SharePoint