Tuesday, July 2, 2013

CAML Query - SharePoint Action Automate Server

I have been working with a product called BPA(business process automation) Automate Server 9 for about 9 months now and I am finally starting to get comfortable with using the tool proficiently. I am using this tool to improve efficiency and reduce human error in processes that we have not been able to remove the human element from. One very neat use is with SharePoint and moving list items between lists, more specifically lists that are not in the same SharePoint site. With that said, I still have my fair share of mistakes and screw ups because let's face it...I'm human! This leads us to the meat of this post, shall we?

In BPA Automate 9(BPA), we can use CAML queries to help us interact with SharePoint Lists and libraries. I needed a CAML query that would limit the number of records to more accurately filter the data returned by SharePoint to improve the efficiency of my workflow. My goal was to avoid looping through all the list items on a SharePoint library because I only needed a list of the files, not folders.

There are a few things that helped me. The first thing is the following link, http://msdn.microsoft.com/en-us/library/dd582942(v=office.11).aspx. This allowed me to see what I needed in my query, using the Query section. The other thing that helped me is a program called CamlDesigner, which can be downloaded from http://sharepoint.biwug.be/Pages/Downloads.aspx. There is more information on how to use this at this link, http://www.camldesigner.com/?p=596.

There are some syntactical problems with using CAML when you are unfamiliar, as I am. I am posting a CAML query below that shows the format that BPA needs it in. The values in "" can all be change as long as the values are real and match what they are in SharePoint.

<View><Query><Where><Eq><FieldRef Name="FSObjType" /><Value Type="Integer">0</Value></Eq></Where></Query></View>


One of the first things that someone who is familiar with SharePoint and CAML queries will notice is that it is not formatted the way you would expect. It cannot be formatted like a normal markup language. It needs to be tight and without spaces like above. (I know, it doesn't seem to make much sense. I can only think that BPA formats it later so they want it in a nice neat string before they format it.)

No comments:

Post a Comment