Office 365 Developer Bootcamp (Microsoft) – Melbourne

Introduction and hands-on LAB on SharePoint Framework Extensions


  • Toolbox
  • SPFx generators – new options
  • Structure overview
  • SharePoint Framework Extensions
  • Deployment
  • Demo
  • Hands-on Lab – Building and Deploying SPFx Extensions
Thanks to Ashish for the photo

Follow up Blog: Global Navigation and Branding for Modern Site using SharePoint Framework Extensions
Upcoming O365 Dev Bootcamp:
Slides can be found here

SharePoint Framework – Introduction to SPFx Extensions

@types SharePoint error – index.d.ts TS1005

The latest version of the @types/sharepoint is throwing the the following error:
Error – typescript – node_modules\@types\sharepoint\index.d.ts(3604,17): error TS1005: ‘,’ expected.
Error – typescript – node_modules\@types\sharepoint\index.d.ts(70,42): error TS2314: Generic type ‘ListItem<T, any>’ requires 2 type

After spending sometime trying to fix the issue, I found the current version of the @types/sharepoint is expecting the new TypeScript Compiler. Issue reported

If you already have installed the latest version, uninstall the version from the solution:
npm uninstall @types/sharepoint

Use the last working version (2013.1.6):
npm install @types/sharepoint@2013.1.6 --save-dev

Note: These are the versions that are available during the time of this post.

Kloud TEDx

Recently we are having lots of discussion in Yammer and in person regarding
• the future of SharePoint Online, Office 365,
• the new capabilities Microsoft is introducing
• how these features will impact the solution we built and so on.
I thought I will use this opportunity to share some of my insight:

I will be focusing on two main burning questions:
• What are the new features and capabilities we are seeing in Office 365 and SharePoint?
• And will we have enough things to do in SharePoint space in future or are we automating away all our jobs?

First the new capabilities. Recently Microsoft has been releasing many tools that will empower end users to do self-service. Tools like

  • Flow – will allow the user to create and automate complex processes involving outlook, SharePoint, OneDrive, Dynamic CRM and many other applications.
  • PowerApps – will allow the user to create mobile-friendly apps, connecting various data source.
  • Power BI – to do analytics on their data.
  • Microsoft Teams – which is chat based workspace. Where user can have common conversation like Slack. Or use Planner as their Kanban board to run an agile project. Any office 365 groups will also get this SharePoint team site automatically for better collaboration.

Microsoft is introducing all these new capabilities, while keeping SharePoint at its core. Even according to the Corporate Vice President, Jeff Teper, this has been the biggest year in the history of SharePoint.

Now in the second part, to understand the future project opportunities, we need to know some stats. Many of you might already have seen this but for the benefit of everyone I will repeat.

Currently 90% of the fortune 500 companies are in Microsoft cloud and 85% are using SharePoint. There are 100 million monthly active users in Office 365 and every month more than 50 thousand small to medium companies are on boarding in Office 365. 50 thousand companies each month. That is a crazy number.

So even with all those exciting capabilities, there is no way Microsoft can meet all the requirements for these businesses. And there we jump in – to develop complex, user-friendly solutions, automate business processes and to connect and integrate with various 3rd party enterprise applications.

With the recent availability of SharePoint Framework, now we can build mobile ready intranet and SharePoint site very easily and apply custom branding, customize the document library or list like a 3rd party datagrid or even introduce our own custom menus and toolbar items.

It is also allowing us to easily connect and authenticate to other office or azure services like graph, webapps, outlook, bot framework etc. There is PnP example of a SharePoint webpart where end user can chat with a Bot and can ask the Bot to create sites and subsites in a site collection. I think in 5 years’ time, it will be essential for an Intranet to have an AI enabled Bot to provide 24 hours’ support. Just imagine how far we can go with that.

Before concluding, I must say and hope you will agree, that there are enormous opportunities coming for us in the new SharePoint and office 365 space, where we can create, automate, powerful, exciting, connected solutions and we all should get thrilled about that.

Embed Yammer Feed – what if it’s blocked?

Embedding yammer feed into a site is super easy and well documented.

There are many scenarios where the yammer feed might throw error. For example:

  • If the user does not have any yammer account yet
  • If yammer is blocked in a particular network etc.

The following JavaScript snippet will gracefully hide the yammer feed error and will show a user-friendly message.

Listening to the error event can be another alternative option but keep in mind, if yammer is blocked, the callback method will never be invoked.

Reading Content Control values programmatically

Content control is one of the cool features in Microsoft Word 2010 (first introduced in 2007). Imaging cases, where a user submits their monthly/yearly report by MS Word file. Those files definitely contain quantitative & qualitative data that need to be entered into the main system, used by the company, for review and future planning. Generally, there are data entry people who entered these values manually; but with very minimal effort we can automate the process.We can give template MS Word file to those users which they will fill up and submit each month/year. In the template file, we will have content controls (textbox, drop down list etc). Programmatically we can extract and process these values very easily. And then we will enter these values into the main system without any delay.


To accomplish this, first enable the developer tab: (Steps from MS):

  1. Start the application.
  2. Click the Filetab.
  3. Click Options.
  4. In the categories pane, click Customize Ribbon.
  5. In the list of main tabs, select Developer.
  6. Click OK to close the Options dialog box.

Create your template by adding controls:

  1. Make sure you are at Developer tab (Marked as [1])
  2. You can drag and drop control from Ribbon (Marked as [2]) and set properties.
  3. Set a meaningful Title (Marked as [3]) which you can use in code.
  4. In case of drop down list add possible value (Marked as [4]).
  5. You can check the “Content control cannot be deleted” (Marked as [5]) to make sure user cannot delete the controls by mistake.

After this you can use the following code snippets to get all values from the doc file.

Make sure you are getting both SdtRun and SdtBlock objects to read entire content controls. To understand the Open XML Object Model you can go through several articles but you must use “Open XML SDK 2.0 Productivity Tool” to explore the file by yourself. It will speed-up the learning process. Here is a screenshot of the tools (exploring SampleSale.docx file)

Feel free to leave any comment 🙂

SampleSale.docx | Code.

FCKEditor in SharePoint (IE & Non-IE)

In SharePoint, we face one common problem while editing a Rich Text field from Non-IE browsers; the field does not have any Rich text editor. There are few blogs and forum posts showing how we can add FCKEditor in Non-IE browser. But after deployment we will no longer have consistent UI in IE and Non-IE browser for that screen. And after deployment, many users also find th FCKEditor more useful and easy than the default SharePoint Rich Text editor.

So in our project, we decided to use FCKEditor in both IE and Non-IE browser. To do this, I spent some time and came up with the following solution. However after deploying the solution we have tested well and we have not found any side effect, which is very nice 🙂


You can download the FCKEditor controls from here. In our case we have unzipped the control in the following location:

C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATECONTROLTEMPLATES

We have to modify four JavaScript file:


C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATECONTROLTEMPLATES\fckeditor

Add the following configurations in the “fckconfig.js” file to add two new toolbar sets:

Why two?

Multi lines of text has two Rich Text type. One is Rich text (Bold, italics, text alignment) and another is Enhanced rich text (Rich text with pictures, tables, and hyperlinks). In above toolbar set I have listed the appropriate ones, those are supported by the field type. However, you can remove controls, if you want.

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATELAYOUTS\1033

Add the following JavaScript at the end of the “CORE.JS” file. While webpage loading, this JavaScript will replace all textarea with FCKEditor dynamically. This will enable FCKEditor control in both IE & Non-IE browser.

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATELAYOUTS\1033

Search with RTE_ConvertTextAreaToRichEdit in the file “BFORM.JS”. You will find two results. One of those is a function. Modify the function and put return; as the first statement of the function. This will prevent the function from being executed. The function will look like the following:

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATELAYOUTS\1033

Follow the same steps as we did for file “FORM.JS”. Search with RTE_ConvertTextAreaToRichEdit in the file “FORM.JS”. You will find one result, a function. Modify the function and put return; as the first statement of the function.

NON_IE.JS (Caution!)
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATELAYOUTS\1033

We should not modify this file any more. To enable FCKEditor in only Non-IE, we need to modify this file. But now we are enabling FCKEditor for both IE and Non-IE. And for that we have modified CORE.JS, which is invoked for all browsers. So we no longer need to modify NON_IE.JS. Well, if you mistakenly modify this file then if you open the page with Non-IE browser, you will find two FCKEditor for each field 🙂

However, I have used JavaScript function SLAC_NonIERichText from this forum.

Which control causes the PostBack

In the page life cycle the Click event, SelectedIndexChanged event and other events raised by the UI controls are called after Page_Load event. But in many case we need to know which control causes the post back in Page_Load/Init function. If we are working with dynamic controls or other complex UI then this information we often need.
To determine if a control causes the Postback or not we can use the following function:


private Boolean CheckIfTheControlCausesPostBack(Control ctr)
   String ctrID = this.Page.Request.Params["__EVENTTARGET"];
   if (ctrID != null && ctrID != "")
      String newctrID = ctrID.Replace("$", "_");
      if (newctrID == ctr.ClientID)
      return true;
   else if (ctr.GetType().ToString() == "System.Web.UI.WebControls.ImageButton" || ctr.GetType().ToString() == "System.Web.UI.WebControls.Button")
      String controlID = ctr.ClientID;
      String controlIDX = ctr.ClientID + ".x"; 
      String controlIDY = ctr.ClientID + ".y";
      foreach (String key in this.Page.Request.Form.AllKeys)
         String newKey = key.Replace("$", "_");
         if (newKey == controlID || newKey == controlIDX || newKey == controlIDY)
            return true;
    return false; 

Understanding Code:

In most cases, this.Page.Request.Params[“__EVENTTARGET”] contains the ID of control that causes Postback. But for Button and ImageButton the property remains empty string. Rather the control ID can be found in this.Page.Request.Form.AllKeys collection. So we have to loop through the collection and find if the ID exists. Notice I am concatenating “.x” and “.y” with control ID. This is because if the control is ImageButton then in that collection it contains ControlID + “.x” and ControlID + “.y” rather than ControlID.


And I am also replacing “$” sign with “_”, because if the control contains in other container (Panel, UserControl etc) then the ClientID of that control is ContainerID1_ContainerID2_ControlID; whereas in the collection it contains ContainerID1$ContainerID2$ControlID. So we have to replace that symbol before comparing.

To know more about Page Life Cycle: ASP.NET Page Life Cycle Overview

Sharepoint Object Browser


This application is a SharePoint site object browser which shows all the contents of a SharePoint site in a tree structure. The main objective of this sample program is to show; how to use SharePoint object model. This sample code is a very easy view of SharePoint development. But to develop in SharePoint these are must a developer should know.



There are lots of sample and help about SharePoint administration and customization. But there are very few samples and examples in SharePoint programming. At the beginning, we really had to struggle to develop WebPart and to understand how object model and other SharePoint stuff work. I am working in SharePoint project for nearly one year and I felt to share some of my experiences with others using different sample application. And this is my first example.


What this application does?
This is a SharePoint site object browser application. In the textbox, followed by label Site Address, enter a SharePoint site address and then press Go button. You will see all subsites and content of subsites will be generated in a tree form in the TreeView control. In that control, if you click on a tree node of type list then the list’s contents will be shown in the bottom DataGridView. In the Grid you will find all columns and rows of that particular list. Even some columns, you will see here, will not be visible from SharePoint site. You can also select a column from the DropDownList and can update value for all rows for that particular column. But as I told, you will be able to see some SharePoint internal columns, those values we can not update.


Download Code

I have published the article on CodeProject. So you can download the source code from there. Link.


Understanding the code

We can take SharePoint site instance (SPSite) from site’s URL. Then we can access that SPSite object’s properties.
SPSite site = new SPSite(uxAddress.Text);
TreeNode rootNode = uxBrowser.Nodes.Add(site.Url);
uxBrowser.NodeMouseClick += new TreeNodeMouseClickEventHandler(uxBrowser_NodeMouseClick);
for (Int32 i = 0; i < site.AllWebs.Count; i++)
     SPWeb web = site.AllWebs[i];
     TreeNode webNode = rootNode.Nodes.Add(web.Name);
     for (Int32 j = 0; j < web.Lists.Count; j++)
        SPList list = web.Lists[j];
        TreeNode listNode = webNode.Nodes.Add(list.Title);
        listNode.Tag = list;
Here you can see, fist we are creating an instance of SPSite from a string (site URL) then we are getting AllWebs which is a collection of SPWeb objects. After that we loop through all SPWeb objects and it contents and extracting its information. While doing so, we are also adding these objects’s name and reference (saving in Tag property) in the TreeView control to generate the tree.

Now if you click on list type tree node, it will take the list reference from the Tag property.

_CurrentSelectedList = ((SPList)e.Node.Tag);
Then Fields property of_CurrentSelectedList will return the column collection of that list and finally _CurrentSelectedList.Items will return all rows (items) in that list. To make the data more presentable, I have added all contents in a DataTable then Bind it to the DataGridView.
When the user clicks on list type tree node, I am also assigning the DataTable as Data Source of the DropDownList. Now the user can select a column and update the column’s value. But one problem may arise, while updating the list; if the user does not have permission to update then it will generate an error. This can be solved by impersonating the Sharepointsystem user by using the SPSecurity.RunWithElevatedPrivileges method. This is a technique to use Object Model with full privilege.
     using (SPSite ElevatedsiteColl = new SPSite(siteAddress))
       ElevatedsiteColl.AllowUnsafeUpdates = true;
       using (SPWeb ElevatedSite = ElevatedsiteColl.OpenWeb(webName))

In between this method, the code will execute with an Administrative (Sharepointsystem) privilege. So we will be able to do any kind of read/update/delete operation. In the code you may also have noticed that I am initiating SPSite, SPWeb (those are created repeatedly) in a using block. This is because SPSite and SPWeb is very resource consuming object. So we have to make sure the instance gets disposed after its use.



I keep the source as simple as possible. Still if someone feels that some areas needed to explain more, you are welcome to ask me.