Show versions of a document from Microsoft SharePoint

In Relatics a webservice and selection can be configured that enables end users to directly relate a requirement to a document from SharePoint. Besides the need of end users to view the metadata of a document from SharePoint, often there is also a need to view previous versions of the document in Relatics. For example, because a new document version can influence the result of a verification. With the help of this article, you will experience how you can extend the interface to show in Relatics the versions of a document live from SharePoint Online.

Required prior knowledge

For this article, I assume that you have already configured a webservice in Relatics to request documents from SharePoint Online, as described here. This configuration is mandatory for a good working webservice, as discussed below.

Configuring a webservice to receive metadata of a document from SharePoint Online

An extra RESTful webservice (example: ‘Relatics - SharePoint - GetDocumentVersions’) is needed to show the versions of a single document, that was created earlier in Relatics using the webservice ‘Relatics – SharePoint – GetDocuments’:

With the following RequestURI you can request the versions of a specific document:

Example of RequestURI: Request versions of a document from SharePoint

[SubsiteUrl]/_api/Web/getfilebyid('[ID]')/Versions

For this webservice, two RequestURI Replacers are used. The first, ‘SubsiteUrl’, replaces the part of the URL related to the SharePoint subsite (e.g. ‘https://my-organization.sharepoint.com/sites/TheConnection’). You need to replace this with your own, specific URL. The second RequestURI Replacer (‘ID’) corresponds to the ID of the SharePoint document.

The result of the webservice received live from SharePoint, is a list of versions for a specific document. It is important to realize that only historic versions of the document are received, not the actual version.

Handling the result of SharePoint Online in the Relatics webservice

The example below shows an example of a Relatics webservice that can be configured to realize the result in the visualization.

In the table ‘XML Adapter Definition’ you can enter an Xpath Expression to interpret the webservice result from SharePoint:

Example of XPath Expression: XML Adapter Definition

//item/d/results/item

In the table ‘XML Adapter Fields’ you can create all the fields from the webservice result that you want to show to end users. A tip to identify the needed fields is to click on the icon ‘Preview’ on the right top of the screen which gives you an XML file with the current, live dataset. In the example above, I have created a subset of the available metadata, which in my opinion is of interest to the project. Of course, you are free to choose which metadata you want to use. Please be aware that it depends on the SharePoint configuration which document metadata is available. SharePoint can be enriched with specific metadata that is relevant to the project.

It is recommended to select an XML Adapter Field in the table ‘Identifying Field’. In this case I have chosen ‘ID’, because this makes each document version unique. Although this webservice creates no data in Relatics, this setting ensures that information in the user interface is well grouped.

Configuring the authentication for SharePoint Online in the Relatics webservice

As with the other web services, on the tab ‘Authentication’, you have to set the option ‘By credentials’ on ‘Enabled’. The settings are similar as the settings for the webservices ‘Relatics – SharePoint – GetDocuments’ and ‘Relatics - SharePoint - GetDocumentDetails’:

Relating the element from the information model in the Relatics webservice

On the tab ‘Connections’ in the table ‘additionally retrieves one instance of’ you can select the element from the information model that is used for the interface with SharePoint Online:

This setting ensures that when you expand the node ‘Document’ in the query, you can drag and drop the webservice node ‘Relatics - SharePoint - GetDocumentVersions’ in the query.

Configuring the query to show the versions from the document

On the detailpage of the document you can create a seperate table. Example: ‘Document historic versions (live from SharePoint)’ with the following query:

As also explained in this article, in the query a node ‘Project’ is used including properties that store the URL of SharePoint for the corresponding project. The values of these properties are used in the node ‘Relatics - SharePoint - GetDocumentVersions’, so the webservice will use the right URL.

The following derived field is used that allows and end user to directly download the document from SharePoint:

Example of Derived Field: Hyperlink to download SharePoint document version

concatenate("<a href='",[SharePoint Base URL],[SharePoint Site URL],"/",[Url],"'>Download</a>")

The final result

In SharePoint Online you can see which versions of a document are available:

When you look in Relatics in the table ‘Document historic versions (live from SharePoint)’, you can see all the historic versions. Here you can see the power of displaying a hyperlink to directly download the version of a document:

Downloads

Upload the RCS file below to your Relatics environment to view the examples contained in this article:

Note: For security reasons, the username and password of the webservice have been deleted. The webservice will therefore not work in the end application. The workspace is useful to view the configuration settings.

About Kris de Waal

After graduating in Business Administration with a specialization in Business Information Management, Kris joined Relatics as a Business Information Consultant. He is eager to learn about new concepts, technologies, IT systems and apply the knowledge in his daily work. In addition, Kris loves to work on new ideas and innovations to get more out of Relatics.

Relatics Portret-120

Contact

Do you need help in applying the techniques and tips in your own case? Or do you have questions, comments or suggestions about this article? If so, don’t hesitate to contact one of our consultants