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

New cmdlet to unlock list item #4457

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
Open

Conversation

reshmee011
Copy link
Contributor

Type

  • New Feature

What is in this Pull Request ?

Files related to new cmdlet to unlock a list item

-src\Commands\Lists\UnlockListItemRecord.cs

  • documentation\Unlock-PnPListItemRecord.md

@gautamdsheth
Copy link
Collaborator

hey @reshmee011 , instead of this CSOM based API request , let's use the graph based one:

https://learn.microsoft.com/en-us/graph/api/driveitem-lockorunlockrecord?view=graph-rest-1.0&tabs=http

Can you modify the PR to do that ?

@reshmee011
Copy link
Contributor Author

@gautamdsheth : Sure I can do that, I will make the changes soon.

@reshmee011
Copy link
Contributor Author

@gautamdsheth : Is there any existing function to retrieve the driveid of the list or library from Graph?
The graph endpoint requires the drive id, if there is already functionality for it, it will help.
https://learn.microsoft.com/en-us/graph/api/driveitem-lockorunlockrecord?view=graph-rest-1.0&tabs=http

@gautamdsheth
Copy link
Collaborator

Hi @reshmee011 , we use PnP Core for this.

Check this :

IFile sourceFile = Connection.PnPContext.Web.GetFileByServerRelativeUrl(serverRelativeUrl, p => p.VroomDriveID, p => p.VroomItemID);

Maybe we can use the VroomDriveId I think. Also, I think the value is same as list GUID value AFAIK, need to check , so list.ID or list.GUID might work

@reshmee011
Copy link
Contributor Author

@gautamdsheth : Thanks for the guidance. I have not tested it yet, will Connection.PnPContext.Web.GetFileByServerRelativeUrl work for list item as well? Is there a method to just get List/library driveid within PnP Core?

@reshmee011
Copy link
Contributor Author

@gautamdsheth : I have used the REST API endpoint /_api/SP.CompliancePolicy.SPPolicyStoreProxy.UnlockRecordItem() which works for both a file and list item. The Graph endpoint works against a driveitem which from my understanding is applicable only to a file. I bet another cmdlet Unlock-PnPFile would work for the Graph endpoint https://learn.microsoft.com/en-us/graph/api/driveitem-lockorunlockrecord?view=graph-rest-1.0&tabs=http

@gautamdsheth
Copy link
Collaborator

Hmm, need to check this a bit about how to fetch driveId via PnP Core.
We want to avoid CSOM moving forward and use Graph where possible especially for new cmdlets. If it's not possible (list item) via Graph, lets not do it.

Will get back to you asap.

@gautamdsheth
Copy link
Collaborator

@reshmee011 - we can fetch the Drive ID and Drive ItemID as below:

IFile fileToDownload = Connection.PnPContext.Web.GetFileByServerRelativeUrl(serverRelativeUrl);
fileToDownload.EnsureProperties(f => f.VroomDriveID, f => f.VroomItemID);

var itemId = fileToDownload.VroomItemID;
var driveId = fileToDownload.VroomDriveID;

We can then use these values in the Graph patch request

@reshmee011
Copy link
Contributor Author

@gautamdsheth :Thank you. Shall I also update the cmdlet to Unlock-PnPFileRecord to reflect that it will be applicable to files and not to list items.?

@gautamdsheth
Copy link
Collaborator

Maybe lets call it Update-PnPFileRetentionLabel ?

@reshmee011
Copy link
Contributor Author

@gautamdsheth : There is another endpoint to update retention label https://learn.microsoft.com/en-us/graph/api/driveitem-setretentionlabel?view=graph-rest-1.0&tabs=http, I can implement is as Update-PnPFileRetentionLabel.

For this one which refers , shall I keep as Unlock-PnPFileRecord with a switchparameter to lock the record?
https://learn.microsoft.com/en-us/graph/api/driveitem-lockorunlockrecord?view=graph-rest-1.0&tabs=http

@gautamdsheth
Copy link
Collaborator

Both of them are point to the same Graph endpoint with different payloads.
Would be great if we can combine both in a single cmdlet with different parameters like name , isRecoredLocked. What do you think ?

@reshmee011
Copy link
Contributor Author

Sounds good, I will have a go at it and reiterate with further changes.

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

Successfully merging this pull request may close these issues.

2 participants