Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Set-PnPListItem not working on lists with more than 12 lookup columns #4311

Open
5 tasks
ohaak2 opened this issue Sep 19, 2024 · 4 comments
Open
5 tasks
Labels
bug Something isn't working

Comments

@ohaak2
Copy link

ohaak2 commented Sep 19, 2024

Expected behavior

Using Set-PnPListItem to update some values of a list item in a list having more than 12 lookup columns shouldn't run into this lookup column threshold issue as long as we are not trying to set more than 12 lookup columns in that operation.

Actual behavior

We will get the error message that the list we are operating on is exeeding the 12 lookup column threshold and thus the query couln't be processed.

Steps to reproduce behavior

  • Create a custom list and add more than 12 lookup columns in total (Person/Group, Taxonomy or actual SP list lookups - no matter what)
  • Try to update a list item in that list - just setting e. g. one of the taxonomy fields.

What is the version of the Cmdlet module you are running?

2.12.0

Which operating system/environment are you running PnP PowerShell on?

  • [ x] Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify
@ohaak2 ohaak2 added the bug Something isn't working label Sep 19, 2024
@ohaak2
Copy link
Author

ohaak2 commented Sep 19, 2024

I've checked the code to clarify why PnP.PowerShell is obviouslty trying to query all list columns while I'm just trying to update e.g just one field.

Found the following code in class ListItemHelper:

image

I think it should be possible to query just the fields that are acutally rerference in the Cmdlets "value" Parameter. That way it should be easy to avoid that threshold issue.

I've verified my theory using the Set-PnPTaxonomyFieldValue Cmdlet on that same list - with no issues at all. Here the code (in Microsoft.SharePointClient.TaxonomyExtensions) is just loading the field in question and everything works fine:

image

@ohaak2
Copy link
Author

ohaak2 commented Sep 26, 2024

By the way - this is the error message we're currently facing:
The query cannot be completed because the number of lookup columns it contains exceeds the lookup column threshold.

I'm even getting this error, if I'm just trying to change the item's content type using Set-PnPListItem. No additional values involved. And all this just because SetFieldValues is trying to load all fields involved (for whatever reason).

@Tanddant
Copy link
Contributor

As a workaround, what happens if you load the item and updated it manually?

Something like this (don't have PowerShell handy right now, but you should be able to get it to work)

$li = Get-PnPListItem -Identity 1
$li["Fieldname"] = "New Value"
$li.update();
Invoke-PnPQuery

@ohaak2
Copy link
Author

ohaak2 commented Sep 27, 2024

@Tanddant Yes, indeed. That's working for me. I've already tested a fix for the code behind Set-PnPListItem. The trick is to avoid the query for all fields as mentioned in my post above:

image

I'm avoiding to load all fields by query. The only fields the code now loads are the ones involved, if you provide any value updates.

My fix so far just involved the single item update - not the batch operation. The latter one is unfortunately far more tricky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@Tanddant @ohaak2 and others