cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jdscott
Helper II
Helper II

Patch expects boolean, not text

I'm trying to update a patch function which is currently working: 

 

Patch( RefHoodList, LookUp( RefHoodList, HoodID = txtHoodID.Text), {HoodID: txtHoodID.Text, Department: txtDepartment.Text, Sensor: togSensor.Value})

I've abbreviated it slightly, but the structure is the same. I want to change the item Sensor from togSensor.Value to txtSensor.Text. txtSensor is a label which changes its Text property when the toggle, togSensor, changes. This allow me to put words in my database instead of a boolean value.

 

Powerapps gives me the following when I try this: 

The function 'Patch' has some invalid arguments

and...

The type of this argument 'Sensor' does not match the expected type 'Boolean'. Found type ' Text'. 

 

Why won't it let me switch to entering text? It allows me to enter text in other items.

1 ACCEPTED SOLUTION

Accepted Solutions
Jdscott
Helper II
Helper II

I figured it out. And no discredit to those trying to help. Thanks!

 

I had another place in the app which collects the information from the database to the RefHoodList. In this location, the data togSensor.Value was being collected to RefHoodList. Once the collect function was amended to collect Sensor: txtSensor.Text the patch function trying to patch the Sensor field of RefHoodList worked fine.

View solution in original post

4 REPLIES 4
PeteMc
Resolver I
Resolver I

It would be based on the data type of the field in your source, you can convert it to a boolean like this
If(Lower(lookup value here)="false", false, true)
v-xida-msft
Community Support
Community Support

Hi @Jdscott,

 

Could you please share a bit more about your app's configuration?

Could you please show more details about the data source within your app? Is it a SP list?

Do you want to save a Text value from your app into the Boolean type column (If your data source is SP list, it is Yes/No type column)?

 

Based on the error message that you mentioned. I think you have faced data type match issue.

 

I suppose that the data source within your app is a SP list, the Sensor column is a Yes/No type column within the list, is it true? when saving data into your SP list, you must provide a Boolean value for the Sensor column rather than a Text value.

 

If you want to save a Text value into the Boolean type column in your data source (it is Yes/No type column in SP list) within PowerApps, I afraid that there is no way to achieve your needs in PowerApps currently.

 

As an alternative solution, you could consider take a try with the solution the user @PeteMc mentioned. Please modify your formula as below:

Patch(
RefHoodList,
LookUp( RefHoodList, HoodID = txtHoodID.Text),
{
HoodID: txtHoodID.Text,
Department: txtDepartment.Text,
Sensor: If(txtSensor.Text="false",false,true)
}
)

Note: The "false" represents the text value within the Label control (txtSensor).

 

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Jdscott
Helper II
Helper II

My data source in an Excel sheet in OneDrive. The Sensor column is formatted as a general column, however, PowerApps has been storing Boolean values in it.

 

My app is configured to run offline a majority of the time, so the data source is copied to a collection (RefHoodList) on startup. This collection is what is being patched. I'm not sure of the data type of the Sensor column in RefHoodList. PowerApps would have automatically determined this when it created the collection. Based on the error message, PowerApps decided it has a boolean data type.

 

My goal is to store a text value in the database based on the boolean toggle.Value that is my control for this field. I have a text box which changes text based on toggle.Value like so -  If( toggleValue, Yes, None)

Jdscott
Helper II
Helper II

I figured it out. And no discredit to those trying to help. Thanks!

 

I had another place in the app which collects the information from the database to the RefHoodList. In this location, the data togSensor.Value was being collected to RefHoodList. Once the collect function was amended to collect Sensor: txtSensor.Text the patch function trying to patch the Sensor field of RefHoodList worked fine.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,094)