cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
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
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)
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.
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)

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
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (13,199)