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

Add new ms_drive_item methods for item version history, analytics, retention labels, etc. #188

Open
elipousson opened this issue Oct 18, 2023 · 6 comments

Comments

@elipousson
Copy link

elipousson commented Oct 18, 2023

I'd be interested in seeing a feature added that allow the retrieval of the version history for a SharePoint item (especially a Word document) when returning the item metadata. This could also be handled as a separate method if that is more appropriate for the package design.

I know how to access the file version history from within Microsoft Word but I had difficulty finding any documentation on how this information can be handled programmatically. I do see that the .NET library has an option for working with document library versions: https://learn.microsoft.com/en-us/dotnet/api/microsoft.office.tools.word.document.documentlibraryversions?view=vsto-2017#microsoft-office-tools-word-document-documentlibraryversions

I also found a couple of references to API endpoints here: https://community.fabric.microsoft.com/t5/Desktop/Getting-version-history-from-SharePoint-document-library/m-p/776338

And here: https://learn.microsoft.com/en-us/answers/questions/1076146/get-version-history-of-a-word-online-document-thro

This may be out of scope for the Microsoft365R package but, if so, I'd still welcome any tips on how to approach this within R. Thanks for the package!

@hongooi73
Copy link
Collaborator

hongooi73 commented Feb 15, 2024

Going from that last link, this should get you the history:

obj <- sp$get_item("path/to/file")
obj$do_operation("versions")

Is that what you're after? Basically do_operation will let you run any Graph API method defined for that object.

@elipousson
Copy link
Author

This is exactly what I wanted to do, @hongooi73. I didn't quite realize it was so simple to use the do_operation method! Would you be interested in seeing this feature added to the package? I could likely put together a pull request with this and a couple other open feature requests over the next couple weeks.

@hongooi73
Copy link
Collaborator

That would be great! I recommend looking at the AzureGraph vignettes if you want to make a PR, there is a short intro on extending the object framework.

@elipousson
Copy link
Author

elipousson commented Feb 15, 2024

Is this the vignette you are thinking of, @hongooi73?

It looks like there are a couple different API endpoints related to item changes, usage, retention, and versioning:

If it works for you, I may change the title of this issue to something a little broader and see if I can put together a pull request that adds a few new related method to the ms_item class objects all at once.

There isn't any kind of official test environment, right? I'd need to set something up with my own SharePoint access for myself to write and run tests?

@hongooi73
Copy link
Collaborator

That would be great! There is a test environment, but it's just my own MS365 account right now. Any business account code is untested. So yeah, you'd have to mock something up on your own, unfortunately.

One note: List children is just your regular file listing, which is already implemented as list_files.

In terms of code style: have a look at the existing code and copy it. In particular, try not to use the Tidyverse unless absolutely necessary. One of my objectives is to avoid bloating the list of dependencies, and pulling in things like dplyr or tidyr can have a big impact. You also mentioned that you're not very familiar with R6. Do you know any of the big languages (Python, Java, C#, C++ etc)? R6 is basically how these other languages do object-oriented programming.

@elipousson
Copy link
Author

Yeah, I mainly work in the tidyverse but I've done enough package development that I can handle alternate workflows in base R. I came to programming via urban planning and public health so R is the only language I "know" but I'm decent at adapting code samples and reading documentation even when it isn't something I'm familiar with.

I'll try to start with a small PR for a drive item version method to make sure I get the conventions right – should take a week or two at most. This package has been a big help to me since a colleague introduced it to me back in the fall so I'm excited to contribute back.

@elipousson elipousson changed the title Access version history for a SharePoint file (Word document or Excel sheet) Add new ms_drive_item methods for item version history, analytics, retention labels, etc. Feb 16, 2024
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

No branches or pull requests

2 participants