Param

How to Use the Power Fx ParamĀ  Function in Power Apps

What is the Param function?

The Param function in Power Fx allows you to pass parameters between screens or components within your application. It can be used to pass simple values like text, numbers, or booleans, or it can pass more complex data like records or tables. The function can also be used to perform actions based on the input received from the user.

Syntax of the Param function

The syntax of the Param function is as follows:


Param(“parameter name”, “default value”)


The first argument of the function is the name of the parameter that you want to pass. The second argument is the default value of the parameter in case it is not passed from the previous screen or component. If the parameter is passed, the default value is ignored.

Using the Param function in Power Apps

To use the Param function in Power Apps, you first need to create a screen or component that will receive the parameter. Once you have created the screen or component, you can add the Param function to the OnVisible property of the screen or component. This will ensure that the function is called every time the screen or component becomes visible.


OnVisible: Set(myVariable, Param(“parameter name”, “default value”))


In this example, the Param function is used to set the value of a variable called myVariable to the value of the parameter passed from the previous screen. If the parameter is not passed, the default value is used.

You can also use the Param function to perform various actions based on the input received from the user. For example, you can use the If function to check the value of the parameter and perform different actions based on the value.


OnVisible:

If(Param(“parameter name”, “default value”)=”Yes”, Navigate(Screen2), Navigate(Screen3))


In this example, the Param function is used to check the value of the parameter passed from the previous screen. If the value is "Yes", the application navigates to Screen2. If the value is anything else, the application navigates to Screen3.

Passing complex data using the Param function

The Param function can also be used to pass complex data like records or tables between screens or components. To pass a record, you can use the Set function to set the value of a variable to the record.


OnVisible: Set(myRecord, Param(“parameter name”, Defaults(myTable)))


In this example, the Param function is used to pass a record called myRecord from the previous screen. If the record is not passed, the default value is set to the first record in the myTable table.

To pass a table, you can use the Collect function to collect the data from the previous screen and store it in a new table.


OnVisible: Collect(myTable, Param(“parameter name”, []))


In this example, the Param function is used to pass a table called myTable from the previous screen. If the table is not passed, an empty table is created.

The Param function is a powerful tool in Power Apps that allows you to pass parameters between screens and components. It can be used to pass simple values like text, numbers, or booleans, or it can pass more complex data like records or tables. The function can also be used to perform various actions based on the input received from the user. By mastering the Param function, you can create dynamic and responsive applications that meet the needs of your users.

Power Apps Training Courses by G Com Solutions (0800 998 9248)