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

Not Understanding Patch error

I am creating a new app for our forklift drivers and it has 2 screens --  a search screen for the driver to lookup a part number, and a second (delivered) screen with a datepicker control, a cancel button and a "confirm" button which should confirm that the driver delivered N quantity of that part for inspection on the date picked.

 

On the scrSearch I set a variable for the part number called "selectedPart".

01-scrSearch.png

 

On the icon's ( > ) OnSelect control, I have the follow statement -- which sets the value of the SP List column named RM-item-Number to the global variable SelectedPart, and then navigates the driver to the second screen called scrDelivered.

02-onSelect-stmt.png

 

This works correctly. However, on the "confirmed delivery" button on the second screen, I get an error.  Here is my onSelect statement for the button:

 

03-OnSelect-scrDelivered.png

 

And here is the error I get:

 

04-error.png

 

The SP List name is Inbound RM Inspection (and it doesn't seem to find an error with that. SelectedPart is the global variable which contains the part number I want to edit in the list, DELIVER-TO-LAB is the column name in the SP List for the date field (delivery date) and DeliveredDatePicker.Selected should be the value of the date to insert into the field. The rest of the compound statement directs the user back to the initial search screen.

 

What the heck am I doing wrong here?

 

Thanks,

gpence

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @gpence,

Based on the error message that you mentioned, I think there is something wrong with the SelectedPart context variable that you mentioned.

The result the SelectedPart variable (ThisItem.'RM-item-Number') would return a Text value or Number value, but the second arguments of the Patch function is required to provide a record value.

I have made a test on my side, please take a try with the following workaround:

Within the first screen, modify the OnSelect property of the Navigate ('>') icon button to following:

Navigate(scrDelivered, ScreenTransition.None, {SelectedPart: ThisItem}) /* Type ThisItem rather than ThisItem.'RM-item-Number'*/

Within the second screen, modify the OnSelect proeprty of the "Summit" button to following:

Patch(
    'Inbound RM Inspection',
     SelectedPart,
     {
       DELIVERED-TO-LAB: DeliveredDatePicker.SelectedDate 
     }
);
Navigate(scrSearch, ScreenTransition.None)

 

In addition, I also agree with @iamlee's thought almost. You could also consider take a try to modify the OnSelect property of the "Submit" button into following:

Patch(
    'Inbound RM Inspection',
     LookUp('Inbound RM Inspection', 'RM-item-Number' = SelectedPart),
     {
       DELIVERED-TO-LAB: DeliveredDatePicker.SelectedDate 
     }
);
Navigate(scrSearch, ScreenTransition.None)

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.

View solution in original post

5 REPLIES 5
Super User
Super User

Don't have an opportunity to check at the moment, but could the issue be the name of 'DELIVER-TO-LAB'?

In your text explanation you have 'DELIVER-TO-LAB' and in the formula you have 'DELIVERED-TO-LAB'.

I'd also check whether you need quotes around that name (due to the inclusion of hyphens) as you have with ThisItem.'RM-item-Number'.

@PaulD1 - I think you're absolutely correct! I think without the quotes around the name, PowerApps most likely interprets the hyphens as the subtraction operator, which then results in the error that we see.
@gpence - Assuming that your column name is DELIVERED-TO-LAB, here's how your formula would look with the quotes round the column name.

 

Patch('Inbound RM Inspection', 
       SelectedPart,
       {'DELIVERED-TO-LAB':DeliveredDatePicker.Selected}
      );
Navigate(scrSearch, ScreenTransition.None)

 I'd also mention that with the standard date picker control, the SelectedDate property returns the control date (rather than Selected). If your formula still doesn't work, that's something else that I'd check.

@timl and @PaulD1 : Thanks for the tips. I did verify the name of the column is DELIVERED-TO-LAB which I had in the formula, so the typo was only in my description of the problem. I added the quotes around the name and used the SelectedDate property so that my formula now looks like this:

 

Patch('Inbound RM Inspection', SelectedPart, {'DELIVERED-TO-LAB': DeliveredDatePicker.SelectedDate});Navigate(scrSearch, ScreenTransition.None)

But now I get the following error:  Invalid argument type (Text). Expecting a Record value instead.

 

That seems to indicate (to me) that it doesn't like the "SelectedPart" (global) variable in the record postion... *sigh*

I have a similar problem and I think Patch needs to know a specific record. You're only passing a text value. In my situation, I did this

Patch(TableName,LookUp(Table,Condition),{Column:Value})

 

I set my global variable though via the 'OnVisible' properties of my screen, but I think your approach should work. 

Set(IDHolder,Gallery.Selected.ID)

then on Submit button, 

Patch(Table,LookUp(Table,Column = IDHolder),{Column: Value})

Community Support
Community Support

Hi @gpence,

Based on the error message that you mentioned, I think there is something wrong with the SelectedPart context variable that you mentioned.

The result the SelectedPart variable (ThisItem.'RM-item-Number') would return a Text value or Number value, but the second arguments of the Patch function is required to provide a record value.

I have made a test on my side, please take a try with the following workaround:

Within the first screen, modify the OnSelect property of the Navigate ('>') icon button to following:

Navigate(scrDelivered, ScreenTransition.None, {SelectedPart: ThisItem}) /* Type ThisItem rather than ThisItem.'RM-item-Number'*/

Within the second screen, modify the OnSelect proeprty of the "Summit" button to following:

Patch(
    'Inbound RM Inspection',
     SelectedPart,
     {
       DELIVERED-TO-LAB: DeliveredDatePicker.SelectedDate 
     }
);
Navigate(scrSearch, ScreenTransition.None)

 

In addition, I also agree with @iamlee's thought almost. You could also consider take a try to modify the OnSelect property of the "Submit" button into following:

Patch(
    'Inbound RM Inspection',
     LookUp('Inbound RM Inspection', 'RM-item-Number' = SelectedPart),
     {
       DELIVERED-TO-LAB: DeliveredDatePicker.SelectedDate 
     }
);
Navigate(scrSearch, ScreenTransition.None)

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.

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 (75,496)