Pages

Sunday, January 3, 2016

CAML Query Builder for SharePoint Online

Introduction


Folks, you might have seen lots of CAML Query Builder tools available for SharePoint On-premise but when it comes to SharePoint Online, we don't find much of the tools available. 

Even if some tools are available, there are lots of problem in installing or configuring them and to make them work especially for SharePoint Online.

Here, I will be sharing an information with you all on from where we can download the SharePoint CAML Query Builder tool for SharePoint Online and how we can configure it.


Prerequisite


I will be sharing an information on downloading a CAML Query Builder tool called SPCAMLQueryHelper tool which you can download from here https://spcamlqueryhelper.codeplex.com/ and can read more information about the same.

Before installing this tool, following things are required as specified in the link above:

  • .NET Framework 3.5, SharePoint 2013 program version uses 4.5 - Well in the website they have specified about SP2013 program version uses 4.5. This is because if you would like to use this CAML Query Builder tool for SharePoint On-premise. But I have installed it in my laptop which has Windows 7 as OS and Visual Studio 2015 without SP2013 to connect it to SharePoint Online.
  • Run on server with SOM installed - Again, this is required if you want to use it for SharePoint On-premise.


How to download


To download this tool, please follow the steps below:

1. Go to this location - https://spcamlqueryhelper.codeplex.com/

2. On the right hand side of the page, click on 'download' button as shown below: 















3. Clicking on 'download' button will download the '.zip' file folder with name as SPCAMLQueryHelperOnline.exe in the download folder of your machine. 

4. Go to that folder and right click on it and under 7-Zip option, click on 'Extract files' and click on OK. 

In case you do not see this 7-Zip option when you right click on the folder then it means you don't have 7-Zip installed in your machine. You can download the same from this location - http://www.7-zip.org/. Otherwise, if you have different file extracting software installed in your machine such as WinZip or WinRar, you can use them as well.

5. Once the folder extraction is done, you will see a new folder is created with the same name i.e. SPCAMLQueryHelperOnline.exe

Double click on it and inside this folder you will find four files such as:

     a) Microsoft.SharePoint.Client.dll
     b) Microsoft.SharePoint.Client.Runtime.dll
     c) SPCAMLQueryHelperOnline - It is an application file or .exe file
     d) SPCAMLQueryHelperOnline.exe - It is a XML configuration file


If you notice here that your download is complete but there is no setup file as such to install and configure the settings for this SharePoint CAML Query Builder tool to use it for SharePoint Online. 

Let's see how we can configure it.

How to configure

To configure the tool, we have to add both Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll files we have downloaded to the Global Assembly Cache (i.e. GAC)

If you have already installed or have Visual Studio in your machine then you can follow the below steps I have specified to add both the files to GAC. 

You can also see MSDN article on how to install an assembly into the Global Assembly Cache from this location - https://msdn.microsoft.com/en-us/library/dkkx7f79(v=vs.110).


How to add both the files in GAC if you have Visual Studio installed


1. Open Developer Command Prompt - To open the same, Windows + R key in your keyboard and type dev in Run window. It will open developer command prompt. 

If the above step doesn't work, click on Start, expand All Programs, and then expand Microsoft Visual Studio. Depending on the version of Visual Studio you have installed, choose Visual Studio Tools, Visual Studio Command Prompt, or the command prompt you want to use. Make sure to run it as Administrator by right click on it and click on Run as administrator.

Additionally, you can also see MSDN article on how to open Developer Command Prompt from here - https://msdn.microsoft.com/en-us/library/ms229859(v=vs.110).aspx

2. Once command prompt is open, type following command in it:

        gactutil -i C:\your_file_location

For example, my complete file location for Microsoft.SharePoint.Client.dll is C:\Users\Downloads\SPCAMLQueryHelperOnline.exe\Microsoft.SharePoint.Client.dll so my command will be:

      gactutil -i C:\Users\Downloads\SPCAMLQueryHelperOnline.exe\Microsoft.SharePoint.Client.dll



3. Once you have typed in the command as specified above, press 'Enter' key on your keyboard and you will see a message in a command prompt as "Assembly successfully added to the cache".

4. Follow the similar steps to add Microsoft.SharePoint.Client.Runtime.dll file as well to the GAC.

5. Once both the files i.e. Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll  are added to the GAC, now open the SPCAMLQueryHelperOnline application file from the SPCAMLQueryHelperOnline.exe folder which was downloaded along with these two ".dll" files.

6. When you will open the SPCAMLQueryHelperOnline application, you will see three options with radio buttons. 

Select the last option as "Use Web Services (Office 365)". This will enable the "Username" and "Password" text-boxes. Enter your SharePoint Online username (ideally your email address) and password as shown below and click on "SUBMIT" button:




7. Clicking on "SUBMIT" button will open below shown window of this application where under the "Site URL" enter your SharePoint Online site URL and click on "Load":



8. Clicking on "LOAD" button will show all the available lists on your sites to your left side under "Lists" section as shown below:



As you can see in the above step, under the "Lists" section on the left side, all the lists available inside your site will be displayed. To start using CAML Query for a list, double click on the specific list and then click on "Query Helper" tab above the "List Name" text-box. 

To learn on how to use this tool or know more about the same, please check this URL - https://spcamlqueryhelper.codeplex.com/

Conclusion

So, here we have seen how we can download the SP CAML Query Helper tool and configure it to connect with the SharePoint Online. 




No comments:

Post a Comment