Sivarajan's Blog

SharePoint | Office 365 | Azure | JavaScript

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.

09222015-1

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

09222015-2

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”.

09222015-3

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.

09222015-4

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.

Comments (3) -

  • Balaji

    11/27/2015 1:09:13 PM | Reply

    Hi,

       The source code is missing in the provided link. Please share the utility code.

  • Sivarajan Raju

    12/7/2015 9:31:03 AM | Reply

    Balaji,

    will update you today evening.

    Thank you.

  • Balaji

    1/4/2016 10:29:05 PM | Reply

    Hi Siva,

    Is it possible to share the code in onedrive or else please share the code to my mail id : balajircs@gmail.com. Thanks for your help.

Pingbacks and trackbacks (1)+

Add comment

Loading