Sharepoint Client Object Model: Read out Version properties - sharepoint

I' reading out the versions of my List with the following code:
string fileUrl = "/sites/dev1/MyTool/Lists/TicketsList/1_.000";
FileVersionCollection fileVersionCollection;
File file = clientcontext.Web.GetFileByServerRelativeUrl(fileUrl);
fileVersionCollection = file.Versions;
clientcontext.Load(file);
clientcontext.Load(fileVersionCollection);
clientcontext.ExecuteQuery();
This works fine and I get a FileVersionCollection object back.
Is it possible to get the information about the changes as you can see in screenshot?
I want to get little reports, e.g.
How long was ticket XYZ in status "New"
Who changed this?
...

Is it Office365 SharePoint instance, because I see that you use CSOM.
I had similar task, but to migrate all the item versions. I also could not find such a functionality provided by the APIs for Office365. You cannot even get the full item metadata for particular version. I had to expose the /_vti_bin/Lists.asmx to get the version items. More on this here: http://sharepoint.bg/post/How-to-get-list-item-field-versions-data-in-Office365-SharePoint-Online.aspx
However as from what I remember getting the version 2.0 of the item will give you all the item metadata, not the diff with the changes, but not 100% sure. At least you will have all version information and you can implement some code to compare versions and get the required differences.
It is not very fast in terms of performance, but it is something.

Related

How to get the publishing state of a given page?

Currently I'm trying to get some information of the publishing state of a given page.
Maybe anybody has an idea for this issue.
Thanks in advance
To get information about the page I use pnpjs to retrieve the pages list item as follows:
const itemOfPageEN = (await sp.web.getList(this._sitePagesUrl).items.getById(idOfPageEN))();
console.log(LOG_SOURCE, "itemOfPageEN", itemOfPageEN);
in idOfPageEN I provide the ID of a translated page, to get the corresponding item back.
In my console.log Output I can not find any attribute, which give me any information about the publishing state of the given page.
The item that is returned in your itemOfPageEN variable should have a property OData__UIVersionString that gives you the Major and the Minor version of the page, i.e. 0.1 or 1.0.
If the Major version is 0, then there is no published version of the page.
If the Major version is 1 or higher, then there is a published version of the page.
There are other endpoints available that give additional information about the publishing state of the page, for example the versions endpoint.
In REST you would add "versions" to the url of the list item that corresponds to the page, like ..._api/Web/Lists(guid'f8ee0b0f-2dd2-4a6b-ad21-6b1e61334d00')/Items(83)/versions.
Then you get detailed information about all versions of the page, including the Moderation Status which corresponds to the Publishing state. It is in the OData__x005f_ModerationStatus property of the version with the highest version number. If it is 0, then the version is a published version.
The other possible values for the Moderation Status are:
Value
Meaning
0
Approved
1
Denied
2
Pending
3
Draft
4
Scheduled
Hth, Matthias

Using Shareplum to access a Sharepoint Document Library and getting an error when updating metadata

I am using Shareplum to upload a file to Sharepoint, and then to update the files metadata. This is all working fine until I hit 5,000 documents in my document library, at which point its failing. The file upload still works fine, but when I run the following code to then update the metadata of the file I just uploaded, I get a 500 Server Error.
`
instanceOfDocumentLibrary = self.site.List(self.sharePointFolder)
fields = ['Name', 'ID']
query = {'Where': [('Contains', 'Name', self.fileName)]}
print("Getting Items")
GetData = instanceOfDocumentLibrary.GetListItems(fields=fields, query=query)
`
It fails at the GetData stage. I suspect what is happening is that when the List is instantiated (instanceOfDocumentLibrary) it only contains 5,000 documents (as per the SharePoint 5,000 document view limit), and so when we do the GetListItems it can't find the 5,001th document that we've just uploaded (self.fileName) because instanceOfDocumentLibrary only contains 5,000 documents.
I'm pretty much a novice here, so any pointers would be appreciated.
So it seems it can't be done using this methodology, as it is a limitation of SharePoint online.
I've therefore switched to using a different library (Office365-REST-Python-Client) which does things in a different way, and seems to work very well for me.

How to fix update list item fields properties values without creating a new version

using Microsoft Graph API to update a Sharepoint 365 list item fields metadata (e.g. document library list item), the item version number is incremented to the next one.
Moreover, this update takes a while (a couple of seconds), and I suspect this is due to the time the system needs to create the new version data.
We also observed that Powershell Sharepoint PNP API commands have the option to call with the "UpdateOverwriteVersion" setting, that makes exactly what we are looking to do with Microsoft Graph API.
We previously made this same question in the GitHub Microsoft API Doc project, where we were adviced to ask in Stackoverflow in order to resolve this faster.
https://github.com/microsoftgraph/microsoft-graph-docs/issues/4909
Example of updating an item in Sharepoint 365 using Microsoft Graph API:
PATCH /sites/[site-id]/lists/[list-id]/items/[item-id]/fields
JSON body data:
{
"OneDummyField": "Example data"
}
Anyway to make the update without incrementing the version?
Thank you very much. Best regards
You can't, it's the way SharePoint is designed (for online anyways, with on prem you can I think). Everytime you make a change the etag is incremented.
You can use JSOM to solve this:
const ctx = SP.ClientContext.get_current();
const list = ctx.get_web().get_lists().getByTitle('My list');
const item = list.getItemById(1);
item.set_item('Title', `Updated with JSOM request, ${new Date().toISOString()}`);
// item.update(); // -> creates new version, updates Editor and modified date
// item.updateOverwriteVersion(); // -> creates no new version, updates Editor and modified date
item.systemUpdate(); // -> creates no new version, Editor and modified date remains untouched
ctx.executeQuery(success, failure);

Exposing Sharepoint Metadata to web service search

Our organization has started a project hoping to use sharepoint to create Electronic Records for Clients rather than the paper method which tends to have documents get lost etc.
I have been tasked with interfacing with sharepoint to find documents associated with a given client. Each document has sharepoint metadata that stores a ClientNumber, but I am having issues finding how to use the QueryService web service to search on this specific field. There are about 30 document libraries I am to search through, so believe the QueryService is probably a better fit for this particular situation than ListService.
I am using VB code to do the searching, and the following is the querytext I am sending to the QueryEx Function.
...<QueryText type='MSSQLFT'>
SELECT rank, title, path, Description, Write, Size, author, sitename, FileExtension, HitHighlightedSummary, HitHighlightedProperties, keywords, IsDocument from Scope() WHERE FREETEXT(DEFAULTPROPERTIES,'" & Me.ClientNumber.Text & "') AND IsDocument = 1 ORDER BY Rank DESC -- </QueryText>...
I would like to be able to include something in the WHERE clause that explicitly says a match must be found in the ClientNumber field but I have yet to find a way to do this, and as a result of this we are getting results where other metadata or one of the document properties such as document size is equal to the client number.
I have found documentation that there is a way to expose metadata through property mappings and this then becomes searchable. I however cannot find a way this is done in WSS 3.0, is this a MOSS 2007 only feature, or a feature available in 2010?
If anyone can tell me if there is possibly some other way to search based on metadata, or give some insight as to where I should be looking for more information it would be greatly appreciated.
You need to install the Search Server Express from Microsoft, it is free and it gives you the MOSS search engine, where you can do anything you want

Problem finding Item List Id in WSS 3.0

I'm having a hard time figuring out how to refer to a specific Item List within a list in SharePoint. I looked up the page in SharePoint Designer and found that the listitem is inside a custom made webpart inside a custom made webpage. I'm coding an event receiver and need to read the information that the user types into that listitem which is a textbox. Does anyone know the code to do this or how to get the guid for the specific list item?
I would appreciate any help I can get. I have tried looking all over the web for the answer. Thanks.
It might be a good idea to edit your question with exactly what you'd like to do with the information you read. However from what you've said so far:
The ID of the item being edited will already be passed through to the event receiver via SPItemEventProperties so there is no need to look it up. If you need to look up a different item in the list (or indeed in a different list altogether), the Accessing list items using the object model page on SharePoint Dev Wiki gives you all of the options. A good general rule is use SPQuery to get best performance on the whole.
Note: There is a pretty good page on the SharePoint Dev Wiki demonstrating how to write an event receiver. It shows how to query and obtain a list item title.
Update after comments:
Once you have an SPListItem object, you can find its GUID through the UniqueId property. In the "Accessing lists" wiki link I've provided above the code samples show how to use the Title property.
Every piece of data you need to access within SharePoint should be available through the object model. This is a simplification, but generally the pages themselves are rendered from template files on the server and combined with data in the database to display to the user. So editing the page programmatically or through its source isn't going to work.
Apologies if I'm making an incorrect assumption but you sound fairly new to SharePoint development. I strongly recommend you read at least the first few chapters of Inside Windows SharePoint Services 3.0 as the inner workings of SharePoint are important to get a good understanding of and this book should help a lot. There is a section of event receivers in it as well.
Have you looked at SharePoint.ListsService Webservice?
string url = "WSS Site URL";
SharePoint.ListsService.Lists lists = SharePoint.ListsService.Lists(url);
XmlNode list = lists.GetList("ListName");
XmlNode xlists = lists.GetListCollection();

Resources