Tuesday, 10 October 2017

Re-Use your Intranet portal mega menu using SharePoint framework extensions

SharePoint Framework extensions is a great new way to customize modern SharePoint sites. The "Application Customizer" SPFx extension provides a way to customize the look and feel of certain sections of moder site such as header and footer. More details here. This gives us the opportunity to develop custom mega menu navigation and place it in the site header of modern sites .

Consider that you have a Communication Site in your tenant (for HR/Admin news etc) which is linked through the mega menu navigation of your Company's Intranet portal. Wouldn't it be great if a user navigating to this communication site was able to see the same mega menu as on the Intranet portal ? I recently implemented a solution that uses SPFx Extension application customizer to do exactly this.
  • For a customer that I was working for, the mega menu links for their Intranet portal site were stored in a custom SharePoint list.
  • A DIV element placed in their custom Master Page acted as a container for the mega menu. JavaScript code retrieved the navigation links (using REST API) from the SP list and rendered the links inside this DIV through JQuery and CSS.
  • The JS and CSS files were stored in the Style library of the portal site collection (all the users having at least read access to this library).

Reusing this in Modern sites ?

<Click on the image to enlarge>

We can re-use all the JS, JQuery, CSS files to render navigation on modern site without having to replicate these files. This can be done as :

1) Reference the JS and CSS files in the SPFx extension. The links will point to the intranet portal site's style library Here is very nice article from Chris O'Brien on how to achieve this.

2) Render the container DIV in SPFx extension through a React Element which can then be used by JQuery (or any javascript code) to render the navigation links.

Since we are using the same JS and CSS files hosted in the intranet portal site, appropriate changes will have to be made to your JavaScript code if it uses any local site's information. For instance, if it uses "_spPageContextInfo" variable to get the navigation links using REST API, the code will have to be changed to always point to your intranet portal site collection.

Implementation :

Start off by creating a Application customizer SPFx extension using Yeoman generator. Make sure you select "Do you want to allow tenant admin the choice of being able to deploy....." to YES in the yeoman generator. This will allow you to deploy the extension tenant-wide and add the navigation to the modern sites across your tenant without feature activation (Add it as a custom action).

Once the project is created, modify the code of your Application customizer typescript file to add CSS and JS references and also to render a REACT element.

Here is the code for the onInit() method of the SPFx extension. It renders a REACT element.

Create a React component in your code

Deploy the SPFx extension to your tenant's App catalog. Once it is deployed, it is globally available. You can now add the SPFx extension to a communication site easily using PnP PowerShell

ClientSideComponentId  is the ID specified in the .manifest.json file of your SPFx extension.

The exact same navigation used in your intranet portal appears on a communication site.

Monday, 22 May 2017

Quick tip - Get all the empty lists and libraries from SharePoint environment using Search

There might be scenarios when you want to identify all the empty list and libraries from your SharePoint environment for general administration / governance reporting / pre-migration clean-up purposes Instead of writing long running scripts looping through the Site Collections and lists, this data can be found quickly using SharePoint search.

Out of the box, there is a crawled property and a managed property in SharePoint that indicate whether a list is empty or not

Crawled property  : ows_IsEmptyList
Managed property : IsEmptyList

By default, the managed property "IsEmptyList" is not Queryable. To be able to query for the empty list data, create a Queryable custom managed property and map the crawled property "ows_IsEmptyList". I have created a managed property called EmptyListFlag

Now using the good old Search Query Tool, I could retrieve all the empty lists in my SharePoint environment. The results will also have some Out of the box lists and libraries which can be excluded through the query or while processing the results.

PS : I have tested this only against SharePoint online only !

Monday, 8 May 2017

Create a simple timer job for SharePoint online using Microsoft Flow

Creating scheduled jobs for SharePoint on-premise environment was pretty straight forward. Develop a timer job and deploy it to the farm and you are done. With SharePoint online, there are a few different ways to develop scheduled jobs, one of which is to create a Azure web job which talks to SharePoint data and runs the required tasks.

However, some organizations/small businesses do not have Azure subscription or the technical ability/developers to develop and deploy an Azure web job. Sometimes, the required functionality of the scheduled job is not too complex to create a Azure web job.

With Microsoft flow, we can easily create timer job-like features that run on a schedule and carry out a few simple tasks.I say simple because when I set out to explore several different scenarios where a Microsoft flow timer jobs can be used for a SP list, I found that Flow lacks several features. While it provides a lot of connectors, triggers, actions and conditions, as developers or power users there are a lot of actions/trigger/functionalities we need that are missing. At the end of this post I'll explain in brief about a scenario I tried to implement using Flow however it did not work out well.

Sample Timer Job

Meanwhile I decided to develop a simple timer job for asset request and procurement process. The job runs on a schedule and moves the "Approved" asset requests from requests list to a separate "Procurement" list. In this post we will see how to

1. Get items from SharePoint list
2. Filter SharePoint list items using a ODATA filter.
3. Loop on the list items
4. Create and delete list item

I have created two lists that will be used in this flow. Asset Request list with NEW and APPROVED requests (choice column) and a Asset Procurement list which will be empty initially.

Navigate to Flow from Office 365 and create a new flow from blank template.

Give your flow a name. The first step we add here is a Schedule action. This will enable us to define a schedule for our process to run periodically.

The schedule can be set based on Minutes/Hours/Days etc as given below

Now, we will retrieve items from Asset Request list. Add a new action and select SharePoint

Select the Get items action

Configure the Get items action. We retrieve the list items from Asset Request list and filter by only the items which are Approved

Now that we have the approved items, the next step is to iterate through the items and create these items in the Asset Procurement list. To add the Loop operation, click "Add an apply to each" action as shown below

We need to tell the loop action which data source it should iterate. Select the 'value' as indicated below. Notice the data source label is the previous action "Get items"

We need to perform two actions now,

1. Create item in Asset Procurement list
2. Delete Approved items from the Asset request list

Add an action to create a list item in SharePoint.

Select the site and list in which the items must be created and indicate the value for each column in target list. Notice that the data source from where we select the value for the item to be created is coming from our previous Get Items action. So the values coming from the Asset Request list will be added to the Asset procurement list.

Now we create a new action to delete the Approved items from the Asset request list.

We need to delete item from the Asset request list. So select the source carefully. Since we have retrieved items from the Asset request list through Get Items action, select the ID from that data source as shown below.

The complete list flow look as shown below.

After the flow execution, our lists look like :

Limitated functionalities :

The limitation or issues mentioned here are something that I noticed at the time of writing this post. As and when updates are pushed to Microsoft Flow, I will try and update this post as well :)

While creating a SharePoint list item through flow, I noticed that we cannot add values to People column and Choice column as of now. There are a couple of more types of columns which are not supported.


Also, the SharePoint get items action only accepts Odata filter and does not support the Odata Select operation.

There might be several other actions/triggers which you may need to implement your business requirement but are not yet available in Flow.

Hope this helps !!

Tuesday, 18 April 2017

Evaluating Distribution list to Office 365 Groups Migration

Microsoft is encouraging customers to adopt Office 365 Groups more and more instead of using simple distribution lists. So much so that when you try to create a DL in Office 365 Exchange admin, the UI to create an Office 365 Group pops-up first :-)   ..and from there you can navigate to the UI to create a simple DL.

The distribution lists in Office 365 tenant can be migrated to Office 365 Groups. This can be done either through the Exchange admin center UI or through Powershell scripts.

Through User interface :

From the Exchange admin, select the Distribution list from Groups and click the “Migrate to Office 365 groups” button

This will upgrade the disctribution list or it will show an error if the DL is not eligible to be migrated. 

Eligibility critera :

Not all types of Distribution lists can be migrated to Office 365 Groups. Here is the documentation that explains what type of DLs are eligible and not eligible for upgrade.

Old documentation ?

At the time of writing this, the documentation in the above posted link mentions that the Moderated DLs and DLs with send on behalf setting cannot be upgraded, however I found this inconsistent. These two types of DLs CAN be upgraded and looks like the documentation is not updated (?)
I posted a query on tech community forum and from the response I gathered that the documentation will be updated soon

I will try and update this post as and when I find that the documentation on Office support site is updated.

Update [8th May 2017]: 

The documentation about the eligibility of the Distribution list for upgrade looks updated now :)


PowerShell approach :  

Microsoft has provided Powershell scripts that evaluate the distribution lists in your tenant and provide a report of eligibilty as to whether the DLs can be migrated to Office 365 Groups or not
I decided to do an evaluation considering a couple of scenarios. From exchange online I created 6 distribution list each satisfying the below criterias

  •  DL with send on behalf setting
  •  Moderated DL
  •  Simple DL with users
  •  DL with external contacts : Mail user and mail contact
  •  Nested Parent-Child DLs

The scripts are available to be downloaded from the Microsoft documentation, You need to connect to the Exchange online in your tenant and then execute the script. On executing the Get-DlEligibilityList.ps1 two files are generated - Open the output files in excel (though these are TXT files)

Evaluation reports 

 DlEligibilityList.txt : This file lists all the DLs and whether it is eligible to be upgraded or not along with reasons and some other useful information such as

-          Owner of the DL
-          Member count
-          Reasons if the DL is not eligible.


      Again, as specified in earlier above section, the DLs with send as behalf and moderated DLs are eligible and CAN be migrated.

       MailUniversalDistributionList.txt : This file contains the properties/settings of the Distribution list and indicates whether the DL is nested in some other DL or not

What happens to the Distribution lists with external “Mail user” or “Mail Contact”

I have a added few external email IDs as Mail user and Mail contact in Exchange online. I created two Distribution lists, one having a Mail user and one having Mail contact.

When you try to upgrade a distribution list with a Mail contact, it fails with the following error as indicated by the the eligibility report.

When you try to upgrade a distribution list with a Mail user, it upgrades successfully. The external mail user is added as a member to the new Office 365 Group.

Sunday, 12 March 2017

Office 365 Groups ecosystem Part 4 : External users and group email settings

Office 365 Groups ecosystem Part 1 - The Basics
Office 365 Groups ecosystem Part 2 - Office 365 Group Team site and permissions
Office 365 Groups ecosystem Part 3 - Create groups from several UI options

External users can be added as "Guests" to the Office 365 Group. Here are the details of what guests can and can't do in the group. Only users outside the organizations can be added as "Guests", users that are a part of organizations can be invited and added as regular members.

The external user receives an email and is registered in Office 365 if the user wishes to collaborate in the group.

Email settings for Office 365 Groups :

Office 365 Group email settings can be administered from the Exchange admin. Navigate to the Office 365 Admin center -> Exchange Admin and Groups

This will show you the groups in Exchange, Your Office 365 groups will also be displayed here. Double click on the group or select and click the Edit icon to change the settings of the group in detail

Can external users send emails to Office 365 groups ?

By default, the users outside your organization cannot send email to the Group mailbox. You can edit this setting from the general tab as shown.

Office 365 Groups ecosystem Part 3 : The O365 group team site and permissions

Office 365 Groups ecosystem Part 1 - The Basics
Office 365 Groups ecosystem Part 2 - Office 365 Group Team site and permissions
Office 365 Groups ecosystem Part 4 - External users and group email settings

As we saw in the first post, a team site gets provisioned automatically when a new Office 365 group is created. The team site has a "Modern" look and feel. The site can be navigate either through the "Browse Library" link in the Files section or through the "Site" link from the Office 365 group.

Private group team site :

A quick view of the permissions on this site can be seen through the link in the settings wheel and a detailed view can be seen from the link "Advanced permission settings"

The site has default members, visitors and owners groups. The Office 365 group itself is added as a security group to the Members in the SharePoint site and has "Edit" permission level on the site collection.

Public group team site :

The Members group of a Public group team site has "Everyone except external users" added to it. This enables any users in the organization to collaborate in the public group.

Who is the owner of this team site ?

The user who creates the Office 365 Group is provided Full control access through the "Owners" group on the team site. Though I could not see that user when I navigated to the Owners group, this appears to be a bug (?) and may be fixed in the next updates.

What happens when a user is directly added to the team site SharePoint groups ?

When a user is added to the team site group (Members/Owners/Visitors or custom group) directly, the user does not become a part of the Office 365 group. When the user navigates to Outlook, he/she will not be able to see the Office 365 Group user experience even though they would be able to work with the team site separately.

Search :

At the time of writing this, the documents from a Private Office 365 group do not appear in the search results. This feature is in the road map and will be rolled out. Refer to the Office 365 road map to keep updated with this. 

Office 365 Groups ecosystem Part 2 : Create groups from several UI options

Office 365 Groups ecosystem Part 1 - The Basics
Office 365 Groups ecosystem Part 3 - Create groups from several UI options
Office 365 Groups ecosystem Part 4 - External users and group email settings

Apart from creating a group from Outlook as shown in Part 1, Office 365 Groups can be created from several other options, few available for Admins and a few available to the users. You can manage the creation of Office 365 Groups in your tenant, refer the Microsoft article : https://support.office.com/en-us/article/Manage-Office-365-Group-Creation-4c46c8cb-17d0-44b5-9776-005fced8e618

For Admins

There are other types of 'Groups' available in Office 365 which you will come across while creating an "Office 365" group as an Admin.

Confusing ?!! Here is a list

1. Distribution list
2. Mail enabled security group
3. Security group
4. Distribution group
5. Dynamic distribution group
6. Office 365 Group -> We are dealing with this :)

Create Office 365 groups from :

- Office 365 Admin center - shown in Part 1 of this post.

- Azure Portal

- Exchange online admin center

For Users :

The users can create groups from Outlook, OneDrive, People and Planner. The UI experience for creating a group from all these portals is almost the same except for Planner. An Office 365 group is automatically created when a user creates a new Plan in the planner hub.

The groups created through any of these options are provisioned with the full features of Office 365 groups like team site, calendar, notebook, planner etc.

Office 365 Groups ecosystem Part 1- The basics

Office 365 Groups is a service intended to be used by people in an organization collaborating closely on things like business proposal, event, a project or for open interaction between a wider audience . It utilizes the existing collaboration tools like document sharing, emails, conversations and planner already available in Office 365 and brings these under a single collaboration experience. It is a quick and easy way to set up all you need to collaborate within a team.

Note : All the content posted in this series is subject to "At the time of writing". Since Microsoft releases updates to the Office 365 functionalities often, I suggest you refer to the Office 365 road map to lookout for any updates in the functionalities.I will try my best to update these posts whenever new features are added to the groups in Office 365.

Here is the complete series of posts

Office 365 Groups ecosystem Part 2 - Office 365 Group Team site and permissions
Office 365 Groups ecosystem Part 3 - Create groups from several UI options
Office 365 Groups ecosystem Part 4 - External users and group email settings

Who can create Office 365 groups ?

By default, any user in Office 365 can create Groups. The Office 365 admin can also create groups through the Admin center.

For users :

The simplest way to create an Office 365 group is through Outlook. Logon to your Office 365 portal, navigate to Mail. In the Groups section you will see an option to create a group. Click Create, enter the details and you are good to use your new Office 365 group

Each group has an ID, Privacy type and an owner. The owner is by default the user who creates the group.

From the admin center :

Navigate to your Office 365 Admin center, Expand "Groups" section. Select to "Add a group". The type of the group must be "Office 365 group". When a group is created through the admin center, an "Owner" has to be assigned to the group as well.

Once the group is created, the user experience is shown as below.

Types of Office 365 groups.

When you create a Office 365 group, you can specify whether you want a "Public" group or a "Private" group. As the names suggest, the private group is intended only for a specific audience and public group for anybody to collaborate. Let's see how the user experience is in both of these.

For this post, I have created two groups, "Public Collaboration Group" and "Private collaboration group"

I have logged in with a user who does not have access to any groups in Office 365. A user can explore groups in an organizations using the "Discover" option in outlook

A private group shows the members of a group and gives the users an option to "Join" the group.Once the user chooses to join a group, an Email will be sent to the group owner with the request,

A user can start collaborating in a public group directly however should Join the group to be a member of the group and have higher privileges.

What happens in the background when new Office 365 group is created ?

A lot of things get provisioned in Office 365 when a new group is created. Here is a list

In Azure :

A group is created in Azure. An Office 365 group is essentially a group in the Azure Active Directory. Navigate to your Azure portal, Select "Users and Groups". Select Groups and you will see the groups created ib Office 365 there. The type of the group is "Office"

In SharePoint :

A SharePoint team site is automatically created when a group is created. This team site will be used for storing documents, group notebook etc. The URL of this team site is "https://tenant_url/sites/[Office 365 Group ID]". The group ID is the one specified while creating the group. The site can be accessed from the link shown below

In Planner

A plan is automatically created in the Office 365 Planner which is helpful to plan tasks and activities for the group. Planner can be accessed from the link shown below.

In OneNote

A OneNote notebook is created for the group. This notebook is stored in the "Site Assets" of the SharePoint team site created for this group, explained in the above section.

Calendar :

A calendar is also provided for the group to schedule meetings and events within the group.