How to Get Value from Text input in Power Apps

In this Power Apps Tutorial, we will see how to get value from text input in Power Apps.

Recently, we were asked by one of our clients to get value from text input. That means when the user inserts any data within the text input control and clicks on a button control, the item will be getting by a data source (Whether it is a collection or SharePoint list). Follow this tutorial, to get the solution.

Along with this, we will cover the below topics based on the Power Apps text input control. Such as:

  • Get value from Power Apps text input using a filter function
  • Get value from Power Apps text input using the search()
  • Get password value from Power Apps text input

Also, Read: How to Get Gallery Item By ID in Power Apps

Get Value from Text input in Power Apps

In this section, we will see how to get the value from a single text input control to a data source.

Here, we are going to use a collection that will display the value that we got from the text input control. To work with these scenarios, the following steps are:

  • On the Power Apps screen, we have created a collection ‘CollName’ on the screen visible property.
OnVisible = ClearCollect(
    ColName,
    {UserName: "Johney"},
    {UserName: "Marly"}
)

Where ColName is the name of the collection and UserName is the name of the collection header.

  • Add a gallery to the screen and connect it with the collection to show the collected data. For this, set the collection name (ColName) on the gallery’s Items property.
Power Apps get value from Text Input control
Power Apps get value from the Text Input control
  • Next, add a text input control to the above Power Apps screen and give a name to the text input control i.e., UserName_txtInput.
  • Add a button control to the Power Apps screen and insert the below expression on the button’s OnSelect property.
OnSelect = Patch(
    ColName,
    Defaults(ColName),
    {UserName: UserName_txtInput.Text}
);
Reset(UserName_txtInput)

As per the above expression, when the user clicks the button the item will store in the collection.

Power Apps get item from text control
Power Apps get item from text control

That’s it! We can see that when we insert any item in the text control and click on the button, the collection (that is connected to the gallery) will get that value from the text input. After that, the text input control will be reset to blank.

Get item from the Power Apps text input control
Get item from the Power Apps text input control

This is how to get an item from the Power Apps text input control.

See also  Power bi gauge chart - How to use with examples

Check out: Power Apps Set ThisItem Value [With Real Examples]

Get value from Power Apps text input using filter

In this section, we will see how to get value from Power Apps text input using the filter function. That means when the user inserts any text in the text input control the item will be within a gallery and will be filtered as per the inserted text value.

To achieve this requirement, the following steps are:

  • We have a SharePoint list named Products List having different types of columns such as single line of text, date column, choice column, image, etc.
  • On the Power Apps screen, we have created a horizontal gallery using the above SharePoint list as shown below:
Power Apps get value from Text Input using filter
Power Apps get value from Text Input using filter
  • On the above screen, add a Power Apps text input control to insert the product’s company and give a name to the text input control.
  • Insert the below expression on the horizontal gallery’s Items property.
Items = Filter(
    'Products List',
    Company.Value = Company_txt.Text
)

Where Company_txt is the name of the Power Apps text input control. As the company is a choice column, it is denoted as Company.Value.

Get value from Power Apps text input using filter
Get value from Power Apps text input using filter
  • Let’s preview the app and insert a specific company name from the list. We can see the galley will display only the data whose value match to the text input value.
Get value from PowerApps text input using filter
Get value from PowerApps text input using filter

This is how to get value from Power Apps text input control using a filter function.

Have a look: How to Select First Item in a Power Apps Gallery

Get value from Power Apps text input using the search()

In this section, we will see how to get the items from the Power Apps text input control using the search function.

See also  How to Get First Word in a String using Power Automate?

That means, when the user inserts any text input control, it will search the items that contain that given text and display those items within a Power Apps gallery.

To work with this scenario, we are going to use the above Power Apps gallery and the following steps are:

  • On the Power Apps screen, insert the below expression on the horizontal gallery’s Items property.
Items = Search(
    'Products List',
    Products_txt.Text,
    "Title"
)

Where Products_txt is the name of the Power Apps text input control and “Title” is the name of the SharePoint list column name.

Power Apps get item from text control by search function
Power Apps get items from text control by the search function

Let’s preview the app and insert a text within the text input control. Now, we can see that the gallery will display only those items whose title contains the specified text from the text input control.

Get value from Power Apps text input using the search function
Get value from Power Apps text input using the search function

This is how to get the value from a Power Apps text input control using the search function.

Get password value from Power Apps text input

In this section, we will see how to get password value from a Power Apps text input control. That means, when the user inserts their password via Power Apps text control, it will retrieve that password value from the text input control and collect them on a collection.

To work with this scenario, the following steps are:

  • On the Power Apps screen, add two text input controls for inserting the user’s ID and password.
Get password value from Power Apps text input control
Get password value from Power Apps text input control
  • On the second text input control, set the Mode as Password.
Get Password value from the Power Apps text input control
Get Password value from the Power Apps text input control
  • Add a button control to the above Power Apps screen that will store the data in a secondary storage or collection. Also, give a text to the button control i.e., Save.
  • Next, insert the below expression on the button’s OnSelect property.
OnSelect = Collect(
    ColUser,
    {
        UserID: UserID_txtInput.Text,
        Password: Password_txtInput.Text
    }
)

Where,

  • ColUser is the name of the collection to store the users’ names and passwords.
  • UserID_txtInput and Password_txtInput are the names of the text input controls for the user’s name and password respectively.
How to get password value from Power Apps text input control
How to get password value from Power Apps text input control
  • Let’s add a data table control to the above Power Apps screen and connect that data table to the ColUser.
  • Add the fields (i.e., User ID and Password) to the data table.
  • Save, publish, and preview the app for now. Insert a user ID, and password into the text input control and press the button control.
  • We can see that the data table is showing the user ID and password as shown below:
power apps text input control get password value
power apps text input control gets password value

This is how to get the password value from the Power Apps text input control.

See also  How to delete all rows in Excel using Power Automate?

Furthermore, you may like some more Power Apps tutorials:

Conclusion

From the above Power Apps Tutorial, we learned how to get value from the Power Apps text input control based on different scenarios such as:

  • Power Apps get value from text input
  • How to get value from a Power Apps text input using a filter function
  • How to get value from the Power Apps text input using the search()
  • How to get a password value from Power Apps text input
>