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

validateUpdateListItem does not work after coAuthoring was enabled #3119

Open
mjonila opened this issue Aug 14, 2024 · 2 comments
Open

validateUpdateListItem does not work after coAuthoring was enabled #3119

mjonila opened this issue Aug 14, 2024 · 2 comments

Comments

@mjonila
Copy link

mjonila commented Aug 14, 2024

Major Version

3.x

Minor Version Number

1.0

Target environment

SharePoint Framework

Additional environment details

SPFX webpart

Expected or Desired Behavior

I have SPFX webpart which is added into the Page. This webpart has Taxonomy picker and users can select tags. This selection is instantly saved into Page field (TaxKeyword). Before coauthoring was enabled - this webpart worked fine. Now it throws error "The file "https://xxxxxx.sharepoint.com/sites/yyyyyyy/SitePages/Testing-keywords.aspx" is locked for shared use by [email protected].". The email in the error is my user email.

When I open Page properties I can save field TaxKeyword manually and then it saves correctly. The difference is that Microsoft's implementation of validateUpdateListItem passes 2 additional parameters:

checkInComments
sharedLockId

I think sharedLockId is essential here, but I have no idea how to generate or retrieve one.
Do you have any idea how this should be solved ?

As a workaround I enabled "Require check out" in Library properties (this disables coauthoring), but our users were waiting for coauthoring feature and want to continue using it.

Do you have any idea how this should be solved ? I did not find anything in pnpjs documentation about sharedLockId.

Observed Behavior

Error while saving page properties. Was working fine before coauthoring was enabled by microsoft.

Steps to Reproduce

Create new Page in Site Pages library and Edit it, leave it in edit mode.
Then create PowerAutomate flow with manual trigger and second action "Send an HTTP request to SharePoint" with Body like this:
{"formValues":[{"FieldName":"Title","FieldValue":"Testing"}],"bNewDocumentUpdate":false}

image

you will receive error 423 : Locked

@daniel-linden
Copy link

I have also encountered this issue, and I want to add some more information.
In the DOM, there is a variable called spClientSidePageContext. When editing a page, this variable contains a CoAuthState object with a SharedLockId property.
image
image

The validateUpdateListItem request URL made by SharePoint when updating fields in the Page Details is slightly different than the PnPJs one, but I am not sure if that is relevant or not.

For me it looked like this: https://{DOMAIN}.sharepoint.com/sites/{SITE}/_api/web/GetList(@A1)/items(@a2)/ValidateUpdateListItem()?@A1=%27%2Fsites%2F{SITE}%2FSitePages%27&@a2='{ItemId}'

When providing the sharedLockId in the body to the above URL, the request works, and the field value is updated. I tried it by by manually finding the sharedLockId and making a request with the spHttpClient. I have not tried to provide the same request body to the PnPJs validateUpdateListItem method.

Unfortunately, I haven't found a (good) way to programmatically get the sharedLockId.

@juliemturner
Copy link
Collaborator

This issue all revolves around first party APIs, specifically the Pages API that currently in PnPjs is a reverse engineered version of those 1st party APIs, for more details see this documentation. At this point since a less robust publicly supported pages API has been GA'd we are in a holding pattern. We could remove our implementation and implement the public one but that will mean removing a lot of the functionality. IF someone wants to take a stab at it, PR's are welcome.

With regard to changes for ValidateUpdateListItem, it's possible new options have been added to the payload other than what we've typed, if you have recommended changes please let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants