Cards For Power Apps
Getting Started With Cards:
Prerequisites
1. Select the text Add and remove element to customize your new card., and then select the Remove icon (X) to delete it.
2. In the left pane, select Insert.
3. In the tool pane, select Input to expand the category, and
then select Text input.
4. In the text input properties pane, set Label to What's
your name?.
Assign variables
1. In the text input properties pane, set Name to UserAnswer.
We're giving the
text input control the name of a variable that we're going to associate with
the user's input.
Tip
Give your
variables descriptive and unique names to make them easier to use in Power Fx
expressions.
We need another
variable to add the user's input to the card title, so let's create one now.
2. In the left pane, select Variables.
3. Select + New variable.
4. In the New variable window, enter UserName under Name and
enter No Name under Default value. Leave the other
values as they are.
5. Select Save.
6. Select the card title, which is a text label control. In the control's
properties pane, set Text to ="Hello " &
UserName.
This expression
changes the card title to the string "Hello " followed by the value
of the variable you created. You can enter the expression in the formula bar or
the properties pane.
Add a Power Fx button
1. In the left pane, select Insert.
2. In the tool pane, select Input to expand the category, and
then select Button.
3. In the button properties pane, set Title to Say
Hello.
4. In the properties pane, select PowerFx to place your
cursor in the formula bar.
5. Type the following Power Fx expression in the formula bar: Set(UserName,
UserAnswer)
This expression
assigns the value of the user's input, UserAnswer, to the UserName variable
you referred to in the card title, when the button is selected. Another way to
read the expression is, "Set the value of the variable UserName equal to
the value of UserAnswer." Since the expression is bound to the
button's OnSelect property, it runs when the user selects the
button.
Test the card
You should always save your changes before you play
a card. Select Save, and then select Play.
Test your card a few times with different inputs.
Make sure your input replaces the default value "No Name" in the card
title each time.
Comments
Post a Comment