cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JanV
Frequent Visitor

Not able to patch a lookup value

Hi all,

 

I'm having problems with a form that patches several columns to a SharePoint list. The problem lies at all the lookup columns in that list. In the examples that I will give below, I'm only using one lookup but I get the same error with all of them. I also added a screenshot as attachment.

 

Error:
- Invalid argument type. Expecting a Record value, but of a different schema.

- Missing column. Your formula is missing a column 'Id' with a type of 'Number'.

- The function 'Patch' has some invalid arguments

 

The patch functions that I tried:

 

Patch(Workspaces, {Id:Blank()},{Title:"Test",Department:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id: Dropdown1.Selected.Id,Value: Dropdown1.Selected.Titel}})
Patch(Workspaces, {Id:Blank()},{Title:"Test",Department:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:LookUp('Department abbreviations',Id = Dropdown1.Selected.Id,Id),Value:LookUp('Department abbreviations',Id = Dropdown1.Selected.Id,Titel)}})

 

 

And almost every scenario to make sure there is no difference between Id < > ID and Title < > Titel (dutch for Title)

 

The weird thing is that I created this app on our dev environment (where it worked), used the export/import action to get it to our acceptance (where it worked) and used the export/import to get it to production (where it doesn't work). So I know that the Patch function at a certain point did work.

 

If we look at the back-end:

On our 3 environments (dev, acceptance, production), the back-end was created using a PowerShell script. So the columns that are created are exactly the same. Did notice that on our production environment the display names did not came through so I did that manually (don't know if that could have something to do with this problem).

I've tried creating a lookup column manually => Same issue

I wanted to make sure the export/import wasn't causing this so I created a new app with a simple button on it => Same issue

 

If you need more information/screenshots, always happy to provide them.

 

I really hope that I'm missing something obvious... 🙂

 

Thanks!

5 REPLIES 5
v-xida-msft
Community Support
Community Support

Hi @JanV ,

Could you please share a bit more about your issue?

Do you want to patch data into the LookUp field in your SP list based on the selected value in your Dropdown box?

Further, could you please share a bit more about the formula typed within the Items proeprty of your Dropdown box?

 

Based on the formula that you provided, I think there is something wrong with it. I have made a test on my side, please take a try to modify your formula as below:

Patch(
Workspaces,
Defaults(Workspaces),
{
Title:"Test",
Department: {
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: LookUp('ReferencedSPList', ReferencedColumn = Dropdown1.Selected.Value, ID),
Dropdown1.Selected.Value
}
}
)

Note: The Department is a LookUp column in your Workspaces SP list, which lookup values from ReferencedColumn in your ReferencedSPList.

More details about saving data into LookUp column of SP list, please check and see if the response within the following threads would help in your scenario:

https://powerusers.microsoft.com/t5/General-Discussion/Cascading-Drop-Down-Result-not-saving/m-p/239...

https://powerusers.microsoft.com/t5/General-Discussion/Save-Filtered-Lookup-Value-in-List-Custom-For...

https://powerusers.microsoft.com/t5/General-Discussion/How-to-patch-a-SP-List-B-Lookup-column-of-SP-...

 

Best regards,

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.
JanV
Frequent Visitor

Thanks for the reply.

Your formula does not work either. Getting the same errors.

My ddlDepartment dropdown is getting its items from a datasource:

'Department abbreviations'

 I already found a workaround by using a hidden form instead of the patch function: https://www.youtube.com/watch?v=YIoFyFQuC_c

But I still want to know what went wrong with my patch function.

 

PDRinoG
Advocate II
Advocate II

Hi,


Was the default site language of your SharePoint set to Dutch?

 

 

Hi @PDRinoG ,

I'm sorry to bring up an "old" thread, but I wanted to ask if there is something special about this problem when your interface is in Dutch. I'm asking because I'm running into this problem again on an environment that is in Dutch. Code that I seem to remember working fine on English environments seems to not work here, and I have no idea why.

So just wanted to ask if there is anything special I should try on a Dutch environment?

Hi @OliverR-82
I have reported the same problem. The default site language of the live environment was in dutch, everything in the app worked in our dev environment (default language English) till it was imported into the live environment. It looks like this is a bug.

https://powerusers.microsoft.com/t5/Building-Power-Apps/Patch-a-lookup-value-Problem-when-the-defaul...

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,054)