Category: Developer

This is a normal case in SharePoint inside Office 365. If you have a new tenancy and you can’t edit the root site collection in SharePoint designer, that’s because editing that root site collection is disabled by default.

Continue reading

Nowaday more and more customer are choosing Office365 and SharePoint Online to host for their enterprise solution, Microsoft just announced about how to use Docker within the SharePoint Framework solution development. Docker provides you an easy way to run multiple different configurations for your SharePoint Framework development by providing isolation with virtualization.

Continue reading

My friends, who also work in SharePoint area, have a lot of requests to accumulate of experience and sometime apply to reality scenarios. That would be fine for me to review the coding skill somehow. By the way, in this article, I can only support three methods to have a cascading field in SharePoint with easiest deploying, understanding and configuring to run its functioning.

Continue reading

Document ready in SharePoint

Last time, my team has worked with javascript on SharePoint page

There are a inject javascript on the page with a Script editor webpart. We did a try to run a function after page load with a common jquery fuction


As our expect, code included inside $( document ).ready() will run once the page Document Object Model (DOM) is ready for JavaScript code to execute. More detail about this function you can find more at

But our problem is the code was not execute as normal. So we work around on this

$(document).ready(function() {

setTimeout(function(){ execute code here},3000);


It works but it was not a good solution.

After research, I cannot remember exactly where, but finally I belive below code is the best solution for this issue.

SP.SOD.executeFunc(‘sp.js’, null, function(){
// Execute code here



Hoang Nhut NGUYEN

Last month, I have worked on a requiremnt with public webiste which using Office 365  SharePoint Online and allow anonymous user submit/add data to a specific list.

As your know, When you enable anonymous access to a Web site, you allow anonymous users (and authenticated users who have not been granted access to the site) to browse the entire Web site, including any list, library, folder within a list or library, list item, or document that inherits its permissions from the Web site.

The issue come from Anonymous cannot submit a Contact Form or a Registration form. That mean, in technically, we can not save information to SharePoint for further requirements.

But happy to know that, there is a customized sandbox solution Wsp365.Anonymous.wsp to allow Administration grant Add/Edit permissions to Anonymous user for any custom list.

You can download the solution here, or codeplex, then upload it to, Active it.

Back to your list, your will see a new ribbon button.


Then you can grant appropriate permission as your expect




Hoang Nhut NGUYEN

SharePoint menu items and ribbon controls are implemented as objects known as custom actions. Custom actions are defined as elements in Extensible Markup Language (XML) files. In SharePoint 2013, it now easy to add and implement ribbon controls with Visual Studio 2012/2013
For understanding, custom actions with Ribbon follow you able to:

  • Create custom action menu items.
  • Create custom action ribbon controls.
  • Access SharePoint objects from custom actions.

Menu items are custom actions incorporated into the built-in SharePoint user interface. As examples, the Site Actions menu is built from a number of built-in, context-sensitive actions that appear as menu item links. And the Site Settings page includes links that are defined by built-in actions. You can build your own custom actions by creating XML definitions in element files in Visual Studio projects, and you can specify where they appear, such as on the Site Settings menu or on a specific administrative page.

Like menus, the ribbon is context-sensitive and shows appropriate actions to users when users need them. For example, when a user browses to a document library, the ribbon controls for adding new folders and documents are shown. SharePoint includes many ribbon controls, and groups them together into related actions. For example, the New Document, the New Folder, and the Upload Document ribbon controls are grouped together on the ribbon

To create a ribbon item, you can use following step on Visual Studio

  1. Right-click Lab09, click Add and then click New Item.
  2. Click Empty Element.
  3. In the Name textbox, type YOURRIBBON and click Add.
  4. After the wizard, just open Elements.xml and check the XML file. Below XML allow you create button with an icon, when user click on it a javascript code will run

Hope this code wil help you understand how to work with Custom Action, CommandUIDefinitions

<Elements xmlns="">
 <CustomAction Id="NewUIRibbonControl"
 RegistrationType="List" RegistrationId="101"
 <CommandUIDefinition Location="Ribbon.Documents.New.Controls._children">
 LabelText="Help Videos"
 <CommandUIHandler Command="showpage" CommandAction="'');" />

Hoang Nhut NGUYEN

How to handle SharePoint web events

If you want to run a small job  such as notify, run a path code job, when administrators or power users on sites perform operations such as Create/Delete a site, Microsoft provide  The SPWebEventReceiver class provides methods that you can override to create these event handlers,
which are run in the following scenarios:

  • SiteDeleting. Before a site collection is deleted
  • SiteDeleted. After a site collection is deleted
  • WebDeleting. Before a site is deleted
  • WebDeleted. After a site is deleted
  • WebMoving. Before the Url of a site is changed
  • WebMoved. Before the Url of a site is changed
  • WebAdding. Before a new site is created
  • WebProvisioned. After a new site has been created

In this article, I will show you how to handle Web event receiver for the WebAdding event. This event receiver will use the  ConfigurationManager class to read the appSetting value. Based on the value of this setting, the Web event receiver either allows or disallows the creation of subsites.

  1. In the Solution Explorer window, right-click yoursolution, point to Add and then click New Item.
  2. Click Event Receiver.
  3. In the Name text box, type ControlSubsites, and then click Add. The SharePoint Customization Wizard appears.
  4. In the What type of event receiver do you want? list, click Web Events.
  5. In the Handle the following events checkbox list, check the A site is being provisioned checkbox.
  6. Click Finish.
    Visual Studio adds an event receiver class with stub methods for the event you chose to handle.
  7. Replace the existing code in the WebAdding event handler with the following code
string configuredValue = ConfigurationManager.AppSettings["YouKey"].ToString();
if (configuredValue == "1")
	properties.ErrorMessage = "Sub webs are not allowed";
	properties.Status = SPEventReceiverStatus.CancelWithError;
	properties.Cancel = true;

Since we are using ConfigurationManager, dont forget to add the namespage

using System.Configuration;
using System.Web;

Hope it help.
Hoang Nhut NGUYEN

SharePoint provides classes that help you work with Web.config entries for your solution in a robust  and simple way. Whenever your solutions need to add, edit, or retrieve Web.config entries, use these  classes, rather than creating your own approaches for working with Web.config files.
This article, I would like to show you

  • Describe the relationship between Web.config files and SharePoint Web applications in a multi-server  farm environment.
  • Add Web.config entries programmatically by using the SharePoint object model.
  • Retrieve and use Web.config entries in your solution code


Web.config entries for a SharePoint Web application affect all site collections in that Web application.

Web.config entries need to be propagated to all Web servers in a SharePoint farm. The SharePoint object model does this for you.
A SharePoint Web Application (SPWebApplication) is analogous to a traditional IIS Web site. In fact, when you create a Web application by using the SharePoint Central Administration application, an IIS Web site is automatically created. You can verify that the IIS Web site has been created by looking in IIS Manager, where you can see its structure, Web.config file, and virtual directory mappings. The Web.config file contains the settings required by the SharePoint Web application, just as that file would do for ASP.NET Web sites.

The settings in the Web.config file affect all site collections, sites, and sub-sites in the SharePoint Web application. Therefore, you must be careful when editing Web.config, as changes normally have farreaching implications.

Below code snippet will show you how to work with App setting for add and modify an keyname

void AddAndModifyKeyName(bool status)
	SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://SharePoint"));
		SPWebConfigModification mySetting = null;
		if (status)
			mySetting = new SPWebConfigModification(); 
			mySetting.Path = "configuration/appSettings";
			mySetting.Name = "add [@key='yourkeyname'] [@value='1']";
			mySetting.Sequence = 0;
			mySetting.Owner = "Yourname";
			mySetting.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
			mySetting.Value = "";
			foreach (SPWebConfigModification modification in webApp.WebConfigModifications)
				if (modification.Owner == "Yourname")
					modification.Value = "";


Hoang Nhut NGUYEN


SharePoint is growing in VietNam, in 1 month, I met 2 CIO and 1 CEO in banking and reseller business domain. They are planning to build up a collaboration platform for their company. A frequently question but important was placed  – “Should we go with SharePoint on-premise or Office 365?”

In this post, I want to focus some limitations of SharePoint Online that I think they’re important to consider before make decisions

1. Storage


Microsoft offer 3 packages with differences storage capability

– SharePoint Online for Office 365 Small Business
– SharePoint Online for Office 365 Midsize Business
– SharePoint Online for Office 365 Enterprise, Education, and Government

But in generally, let’s make a simple calculation for 10 users which suitable for these 3 packages

  • Team site storage = 10GB + 0.5GB per user
  • Public web site storage = 5GB
  • OneDrive for Business = 10 x 1TB = 10TB (Microsoft just upgrade OneDrive for business from 25GB to 1TB. And please keep in mind that OneDrive will be used for individual people, that mean you can not share it to any team site)
  • Maximum file size you can upload to SharePoint Online can be configured is 2GB per file.

2. Synchronization


OneDrive (SkyDrive old name) can be synced with your desktop version. That mean from your desktop, you can configure to sync your folder with OneDrive as well as a Team Site library. And there are some numbers would be reminded:

  • Can not sync >20,000 items in both SharePoint Online Team Sites + OneDrive
  • Can not sync >5,000 items from SharePoint Onnline Team Sites Library

3. SharePoint Online Site Collection

When you buy a package of SharePoint online as mentioned above, you will get a Site collection with sites/subsites hierarchy. It’s designed numbers of site collection, sites/subsites for your package:

  • Small Business: a single Team Site Collection.
  • Midsize Business plans: limits 20 Team Site Collections.
  • Enterprise, Education, and Government:  limits to 10,000 Team Site Collections.

In all options, just single Public Web Site Collection can be created, 1TB for My sites, 2000 site/subsite per site collection

4. Development Limits


Sandbox Solutions was designed to allow SharePoint developer can customize/develop on Office365/SharePoint Online. Some important limitation you have to consider when go with online solution

  • No access to file/folder. It mean you can not use IO API commands
  • Only be deployed at a site collection level scope (not farm scope)
  • No access to web.config
  • PDF Documents cannot be opened in the browser
  • Restrictions to access security
  • Cannot overuse system resources
  • Limited Server Object model

5. Connection


Most important is the availability and stability of Vietnam connection to Office365.  We have faced with severals of time that we dropped connection by optical cable issues with providers in VietNam. All data will be difficult to reach and very slow connection to download/upload files. If you are decision maker, keep it in mind for the backup connnection solution. Your business in the cloud and make sure it’s always stay in touch.

Hoang Nhut Nguyen
Skype: hoangnhut.nguyen

SharePoint 2013 – CSOM

Since SharePoint 2010, Microsoft announced Client object model to developer community and it really help to extent SharePoint to many other platform.  SharePoint client object model (CSOM) allow you to manage data in SharePoint such as list data, user profile, ….

In SharePoint 2013, I’m very impressive with CSOM since it support for multiple plat for

  • .NET Framework redistributable assemblies
  • JavaScript library
  • REST/OData endpoints
  • Windows Phone assemblies
  • Silverlight redistributable assemblies

This artile show a code snippet for demo how to get user from a list data

        public static User GetUserFromAssignedToField() 
            string strUrl="http://" + Environment.MachineName; 
            // create site context 
            ClientContext ctx = new ClientContext(siteUrl); 
            // create web object 
            Web web = ctx.Web; 
            // get Tasks list 
            List list = ctx.Web.Lists.GetByTitle("MyList"); 
            // get list item using Id e.g. updating first item in the list 
            ListItem targetListItem = list.GetItemById(1); 
            // Load only the assigned to field from the list item 
                             item => item["AssignedTo"]); 
            // create and cast the FieldUserValue from the value 
            FieldUserValue[] fuv = (FieldUserValue[])targetListItem["AssignedTo"]; 
            User user = null; 
            for (int i = 0; i < fuv.Length; i++) 
                Console.WriteLine("Retrieved user Id is: {0}", fuv[i].LookupId); 
                Console.WriteLine("Retrieved login name is: {0}", fuv[i].LookupValue); 
                user = ctx.Web.EnsureUser(fuv[i].LookupValue); 
            return user; 

For more detail about CSOM: You can find at on MSDN

Hoang Nhut NGUYEN

%d bloggers like this: