Sivarajan's Blog

SharePoint | Office 365 | Azure | JavaScript

How to automate the Content Types provision in SharePoint Online using Client Object Model – Part 2

This post is a continuation of the previous post. We have discussed that how to automate the Site Columns creation using Client Object Model. Now we will see that how to automate the Content Types creation. 1. Download and open the “SiteProvising” solution. 2. Once you create the site columns as I mentioned in part 1, we are ready to create the content type. 3. Right click the “Contoso.IntranetAssets” project and add the new folder “Content Types”. 4. Right click the “Content Types” folder and add the new item “Content Type” and name it as “Employee” and leave the base content type as “Item”. 5. Now select the site columns “Employee Name”, “Employee Age” and “Employee Address”. 6. Now run the “SiteProvisioning” project and select the option “Content Types”. 7. All the site columns will be created in the associated site collection. Here is a source code for Content Type automation. You can create the multiple content types under the folder “Content Types”. The above code will collect all the content types’ elements files and provision in the associated site collection. I have detailed blog here why I choose this approach.

How to automate the Site Columns provision in SharePoint Online using Client Object Model – Part 1

In SharePoint on-premises, we can connect site collection directly with Visual Studio and can able to provision the site columns using element files. But Visual Studio does not support the same operations for SharePoint Online and will support only for Add-Ins / SharePoint Apps (Provider/hosted). Here are the alternative options for creating the site columns directly with site collections in SharePoint Online. 1. SharePoint User Interface through browser. 2. SharePoint Designer 3. SharePoint Online Client Object Model 4. SharePoint Online PowerShell + Client Object Model From Vesa Juvonen blog, you can find the sample for creating the Site Columns, Content Types using SharePoint Online Client Object Model http://blogs.msdn.com/b/vesku/archive/2014/03/20/office365-multilingual-content-types-site-columns-and-site-other-elements.aspx http://www.microsoft.com/en-us/download/details.aspx?id=42038 We need to write a lot of coding for provisioning the Site Assets using the Client Object Model. To overcome this issue, I wrote a small utility for that. In SharePoint on-premises, we can connect site collection directly with Visual Studio and can able to provision the site columns using element files. But Visual Studio does not support the same operations for SharePoint Online and will support only for Add-Ins / SharePoint Apps (Provider/hosted). Here are the alternative options for creating the site columns directly with site collections in SharePoint Online. 1. SharePoint User Interface through browser. 2. SharePoint Designer 3. SharePoint Online Client Object Model 4. SharePoint Online PowerShell + Client Object Model From Vesa Juvonen blog, you can find the sample for creating the Site Columns, Content Types using SharePoint Online Client Object Model http://blogs.msdn.com/b/vesku/archive/2014/03/20/office365-multilingual-content-types-site-columns-and-site-other-elements.aspx http://www.microsoft.com/en-us/download/details.aspx?id=42038 We need to write a lot of coding for provisioning the Site Assets using the Client Object Model. To overcome this issue, I wrote a small utility for that. Instead of developing a user interface for provisioning this site assets, I thought to reuse the Visual Studio capabilities here. Let’s go step by step. 1. Download and open the SiteProvisioning Visual Studio solution. Download Source Code 2. Right click the “SiteProvisioning” solution. Click “Add” and then “New Project”. 3. Select the “App for SharePoint” under the Office/SharePoint in the “Add New Project” dialog 4. In the “New app for SharePoint” dialog, provide the debug URL and select the “SharePoint hosted” option. 5. Enter the credential to connect with your SharePoint Online. 6. Now we can see that the new project “Contoso.IntranetAssets” will be added with the existing project “SiteProvisioning”. Note : I created this SharePoint hosted App is only for utilizing the Visual Studio user interface for creating the Site Columns, Site Content Types, Pages, etc.,) and we won’t deploy the SharePoint hosted App anywhere. 7. Right click the solution “Contoso.IntranetAssets” and add the new folder “Site Columns”. 8. Right click the “Site Columns” folder and add the new item. 9. Select the “Site Column” template under “Office/SharePoint” and enter the name as “Employee Registration. 10. Open the “Elements.xml” file under the “Employee Registration” site column folder and the columns “Employee Name”, “Employee Age” and Employee Address”. 11. Similarly, we can create the multiple site columns under the “Site Columns” folder. 12. Here is the code snippets for creating the site columns using client object model. 13. Run the SiteProvisioning project and then provide the site collection credentials. 14. On clicking the “Provision” button, all the site columns related elements files will be located from Contoso.IntranetAssets project location and then site columns will provisioned in the site collection. 15. By changing the site collection URL, we can easily provision the site collection in DEV, QA or Production site. In the next post, we will see that how to automate the Content Types provisions.

Portals Development Challenges in SharePoint Online

I had an opportunities to work with SharePoint Online and Windows Azure related implementations for the last one year. Initially I was struggled a lot to setup a proper development process in SharePoint Online like SharePoint on-premises. We can find a lot of code samples in Office PnP for SharePoint Online development. For the same implementation, we can find the multiple approaches in Office PnP. Even though we don’t have a proper Application Lifecycle Management process for SharePoint Online development. If we want to setup a proper development setup for SharePoint Online like On-premises, we should know that what we are missing in SharePoint Online comparing with on-premises. Let’s take an intranet portal development scenario and recap how we did the same implementation in SharePoint on-premises. How we implement an Intranet Portals in SharePoint on-premises? Here are the list of activities we will follow in SharePoint on-premises for implementing a portal. 1. Setup the environments (Development, QA and Production). 2. Build the SharePoint solutions (WSP) using Visual Studio. Each WSP files may have the following items, a. Modules - Which contains the Master Pages, Site Pages, Page Layouts, Branding Assets ( CSS Style sheets, JavaScript files, 3rd party libraries) b. Site Columns c. Content Types d. List and Library schemas e. Visual and Standard Web Parts (using server side C# or VB.NET code) f. Application Pages g. Visual Studio based Workflow h. BDC model files for Business connectivity Services. i. Feature activation or deactivation code block and event receivers. j. Custom Timer Jobs 3. Deployment PowerShell scripts. 4. If everything is working well in DEV environment then, deploy the same WSP solutions in QA and then production environment. Comparing the Licensing model between SharePoint on-premises and SharePoint Online. Understanding the licensing model is important factor for setup the environments. Let’s assume we are planning an intranet portal for 1000 employees in Contoso Inc., SharePoint on-premises Here the license model will be the combination of SharePoint instances and the number of users count. So we will buy a SharePoint Server licenses for DEV, QA and PROD environments and also a user CAL licenses for 1000 users. SharePoint Online Here the license approach is different and there is not instance based license model. So will buy a licenses based on user counts and not server instance basis. Here are the few licensing options. For setup a full blown environments like on-premises (DEV, QA and PROD), we need to buy a three different domains like contoso.dev, contoso.qa and contoso.prod with 1000 user’s licenses for each domain. This approach is too expensive. Alternatively, buy the single domain with 1000 user’s licenses. We can create and use the multiple site collections for DEV, QA and PROD for intranet portal implementation. But the main challenges are with shared services like Content hub, Taxonomy and Search. This is a cost effective option also. Available Development Approaches in SharePoint Online Let’s see the available development approaches for SharePoint Online development 1. SharePoint Add-Ins based development (or Apps) As my experience, we can develop a multiple isolated modules like leave requests, meeting requests, and employee directory using Add-Ins approach and cannot develop or provision a full blown Intranet Portals using SharePoint Add-Ins. Because each app is loading inside an iframe and have lot of challenges in sharing and presenting the data. Already we have a lot analysis regarding the traditional SharePoint solution development vs. Add-Ins (App) and I am not going to write here the same again. 2. PnP provisioning Engine Customizing the sites using browser and/or SharePoint designer and then use PnP provisioning Engine for moving the customizations from DEV to QA/PROD. Office PnP team has recently released this option for moving customization from one site collection to another. Still the framework is in development and not production ready. 3. Remote Provisioning using Client Object Model Office PnP team has released the SharePoint Online Client SDK and we can provision the customization programmatically. For more information about the remote provisioning http://www.sharepoint-reference.com/Blog/Code%20Samples/Introducing%20the%20PnP%20Provisioning%20Engine.pdf SharePoint Online PowerShell. PowerShell support has enabled for SharePoint Online recently and we cannot provision all the options like SharePoint on-premises. By using the combination of above features, we can build the portals in SharePoint Online. Common Development Activities in SharePoint We can divide an entire portal development activities into three main categories, · Provisioning · Customizing the Out of box features · Custom implementation/development Provisioning As we discussed above, we have multiple options are available for site provisioning in SharePoint Online. But I prefer the remote provisioning using SharePoint Online Client Object. Initially it will required a lot of efforts for building the framework. But the deployment will easier and controllable by developer at any time. 1. How to automate the Site Columns provision in SharePoint Online using Client Object Model – Part 1 2. How to automate the Content Types provision in SharePoint Online using Client Object Model – Part 2 3. How to automate the Lists and Libraries provision in SharePoint Online using Client Object Model – Part 3 4. How to automate the Site Pages provision and embedding the Web Parts in SharePoint Online using Client Object Model – Part 4 5. How to automate the Pages Layouts provision in SharePoint Online using Client Object Model – Part 5 6. Feature Stapling in SharePoint Online using Client Object Model – Part 6 7. Managing the Roles and Site Permissions in SharePoint Online using Client Object Model – Part 7 8. Provisioning the current and global navigations in SharePoint Online using Client Object Model – Part 8 The next series of post, I will cover the OOB customization and custom development.