Wednesday, June 29, 2016

Show Created date from Sharepoint document library via Word Quick parts

In Word it is possible to add Sharepoint metadata fields directly to the document: Insert > Quick parts > Document properties. The problem however is that we can’t show value of OTB Created field which contains datetime when document was added to the document library (don’t mix it with file created datetime which is shown when we check file properties in Windows explorer):

Fortunately there is workaround which can be used for achieving the same result. The idea is that we will create new custom field CreatedQP and will copy value from Created field to it. The question is how exactly values will be copied. First approach which comes to the mind is to created calculated field which will just copy value from Created field:

However if we will check available document properties in quick parts we will see that newly created calculated field is not shown there as well. So the only option is to create regular DateTime field and then copy value from Created field to it whether by using workflow or event receiver. In this article I will show how to do it via workflow.

So first of all we need to create new field:

After that we open parent site in Sharepoint Designer and create new List workflow for our document library:

Add new action “Update List Item” and configure it to copy value from Created field of current list item to CreatedQP field:

and finish workflow:

After that we configure workflow to start automatically when new document is added to the document library:

and publish workflow.

Now if we will add new document to the document library, open it in Word and add CreatedQP via Quick parts > Document properties:

created datetime from Sharepoint doclib will be shown in the document:

The drawback of this approach is that users will be able to change value of CreatedQP field via Quick part control. One possible way to avoid it is to try to make CreatedQP field readonly, but I didn’t test this approach by myself.

Tuesday, June 28, 2016

Problem with Azure Media Player and html5 video preload in Chrome

In one of Sharepoint Online site we are working over Azure Media Player was used for playing the html5 videos on the page. This player works on top of standard html5 <video> tag and has a lot of additional features comparing with basic html5 video player built in to browsers. Performance audit made for pages where it is used showed that browser downloads the whole video mp4 file on page load. Video files took Mbs of data and were the biggest part of overall recourses size being downloaded.

Html5 video tag has special preload attribute using which we can control video preloading behavior:

Value Description

The author thinks that the browser should load the entire video when the page loads

metadata The author thinks that the browser should load only metadata when the page loads
none The author thinks that the browser should NOT load the video when the page loads

However after setting preload to none, Azure Media Player (we used latest version 1.6.1) stopped working in Chrome (in IE and FF it worked): it showed video download progress indicator infinitely and when you clicked on the video thumbnail nothing happened:

So for now we decided to switch to the basic html5 video player which doesn’t have this issue and works in all browsers (also tried, but didn’t find significant value which it adds comparing with basic html5 player). Although preload attribute itself is not supported in Edge, but this is different story).

Tuesday, June 21, 2016

Disappeared permissions for “Everyone except external users” in Sharepoint Online

Recently we faced with interesting issue in Sharepoint Online: for some parts of the intranet unique permissions were used. And for these securable objects we used special Sharepoint “group” (which is actually not real Sharepoint group) – Everyone except external users. One the same securable objects there were also permissions assigned to normal Sharepoint groups. After some time without any actions from our side permissions assigned to “Everyone except external users” group disappeared, but permissions assigned to normal Sharepoint groups not.

For now we solved it by using new Sharepoint group which has other AD group which in turn has all users in organizations and new employees are added there automatically (fortunately customer’s administrator had this group), but anyway this is quite interesting problem. So if you will face with the same issue or will find reason of this behavior please share it in comments.

Thursday, June 2, 2016

Remove duplicates in calendar overlays in Sharepoint

In Sharepoint calendar it is possible to have events of different categories and create separate views for each category. Also it is possible to create calendar overlays, i.e. combine these views to the single view where events from different categories will be displayed using different colors. However there is a problem with this approach that events in overlay will be duplicated by default. In this article I will show how to create these overlays and how to fix issue with duplicated events.

Let’s start from creating calendar overlays. At first we need to define event categories in List settings > Category field (choice) > specify needed categories. In our example we will use the following categories:

  • Meeting
  • Work hours
  • Business

After that create view for each category from the list ribbon Create view. For each view we create filter on Category field like shown on the following picture and use category as view name:

and repeat this step for each category. After that we can create calendar overlay. It is done also from ribbon Calendars overlay button which opens the following page:

As you can see by default it doesn’t contain any calendars. Click New calendar link here and specify Name, Color and View for the new layer in the calendar overlay. In order to populate calendar list and all created views we will need to create Resolve button first. Also it is good practice to use the same name for the overlay as view name (and as category name):

Also repeat this step for each category. After that our default calendar view will look like this:

Now let’s create one test event e.g. for Meeting category. It will look like this:

As you can see created event is duplicated in the view. In order to solve this issue we need to edit default calendar view as well and specify filter for Category field. We can set filter there that only events which don’t belong to any category should be shown there (Category is equal to “” (empty string)) or we may apply more complex filter and show only those events which don’t correspond to any mentioned categories. In last case if new category will be added in future events which correspond to this category will be displayed in the default view (unless separate view won’t be created and added to overlay. In this case you will need to add it to the filter of default view as well in order to not get duplicates again):


At the end calendar will look like this:

and as you can see there are no duplicates anymore.