Karine Bosch’s Blog

On SharePoint

New release of CAML Designer available!


042813_0652_Newversiono1.png

My friend Andy Van Steenbergen and I worked very hard to prepare a new release of the CAML Designer. We didn’t aim at adding new functionality; we rather preferred to solve a number of bugs. You can download the new version on the BIWUG site under the Download tab.

We also have the impression that the server object model works much slower than the client object model. Therefore we switched the default work mode to client object model.

There are also a number of bugs that were reported but that are not included in this release:

  • The <Membership> element is missing
  • For complex queries, the CAML query can be included in the REST call
  • Taxonomy fields: only top-level of multi-select field was visible

The reason why these bugs are not solved yet, is because these bugs are not that simple to solve and we didn’t want to wait much longer with this release because of the fixes that are already in it. We will try to solve the remaining bugs as soon as possible.

We hope you enjoy the improvements. If you would encounter bugs or have a good idea on how we could further improve the CAML Designer, please don’t hesitate to report it to camlfeedback@biwug.be  or leave a note on this blog. Together we can make it a better tool.

Show hidden fields

In some cases you want to build a filter based on a value in a hidden field. By default the CAML Designer doesn’t show hidden fields. To solve this issue we added the check box “Show hidden fields” to the user interface just above the list treeview. By default the hidden fields are not displayed, but you can click this check box to get them displayed.

Show hidden fields

Long Display Names

One of our users als reported that there were issues with long display names. It would ask a lot of redesign to have this properly displayed so we chose to add a tooltip that shows the complete display name. We hope that this suits your needs.

Long display names

Boolean fields

There was also a problem with querying boolean fields. This issue is now solved:

  <Where>
      <Eq>
         <FieldRef Name='VeryTall' />
         <Value Type='Boolean'>1</Value>
      </Eq>
   </Where>

I tested and retested, and this query returns rows:

Boolean field query result

User and UserMulti fields

There were a number of problems when filtering on a User field or UserMulti field. These have been solved. Now, you can choose between filtering on the current user or on a specific user.

User field - current user

If you choose to filter on the current user, your query will look as follows:

   <Where>
      <Eq>
         <FieldRef Name='AssignedTo' />
         <Value Type='Integer'>
            <UserID />
         </Value>
      </Eq>
   </Where>

If you choose to filter on a specific user then you can enter or the name of the user or its ID. If you enter the name of a user, your query looks as follows.

   <Where>
      <Eq>
         <FieldRef Name='AssignedTo' />
         <Value Type='User'>Karine Bosch</Value>
      </Eq>
   </Where>

If, at the other side, you want to filter on the user ID, the following query is generated, indicating that you are passing an ID:

   <Where>
      <Eq>
         <FieldRef Name='AssignedTo' LookupId='True' />
         <Value Type='Integer'>4</Value>
      </Eq>
   </Where>

The FileRef field

There was also a problem when trying to filter on FileRef. When you now select the FileRef field on the Where tab, you get a lookup displaying all folders in the selected document library.

FileRef field

When you select a folder, the query is built as follows:

   <Where>
      <Eq>
         <FieldRef Name='FileRef' />
         <Value Type='Lookup'>/Shared Documents/Folder 2</Value>
      </Eq>
   </Where>

REST snippet for lookup fields

Based on a blog post of Andrew Connell “Applying Filters to Lookup Fields with the SharePoint 2013 REST API“, we also updated how the REST snippet for lookup fields is generated:

$.ajax({
   url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Cities')/Items?$expand=Country/Title&$filter=Country/Title eq 'France'",
   type: "GET",
   headers: {"accept": "application/json;odata=verbose"},  
   success: onDataReturned; 
   error: onError; 
   function onDataReturned(data){ // TODO: handle the data }; 
   function onError(err) { // TODO: handle the error }
});

Taxonomy Fields

We also added functionality to retrieve list data based on the ID of a taxonomy field. The difficulty here is that a term has a name and an guid in the term store. You can retrieve list data based on a term name but this is dangereous as term names can change over time.

Taxonomy Field

   <Where>
      <Eq>
         <FieldRef Name='Technology' />
         <Value Type='TaxonomyFieldType'>SharePoint</Value>
      </Eq>
   </Where>

When a term is used to tag a list item, this term is stored in a hidden list on site collection level. At this time, the term gets an ID, which is stored internally as WssId.

This release of the CAML Designer now offers the possibility to query on this ID:

Taxonomy Field by ID

The query instantly changes as follows:

   <Where>
      <Eq>
         <FieldRef Name='Technology' LookupId='True' />
         <Value Type='Integer'>1</Value>
      </Eq>
   </Where>

It will retrieve the same list items as when you would have queried on the term “SharePoint”.

The Test tab

The Test tab displays now a label that indicates the number of rows that are returned by the result set. Once the number becomes visible, you know that the retrieval has finished. This is handy when your query does not return a result and no grid becomes visible. The number zero will indicate that the query is finished but that no results have been returned.

March 17, 2014 - Posted by | CAML Designer, SharePoint 2013

4 Comments »

  1. Reblogged this on Collaboration.

    Comment by Collaboration | March 24, 2014 | Reply

  2. […] New release of CAML Designer available! […]

    Pingback by SharePoint 2013: Recopilatorio de enlaces interesantes (XXXI)! - Blog de Juan Carlos González en Geeks.MS | April 1, 2014 | Reply

  3. Hey Karine,

    Thanks for the great work. Do you know off hand if its possible to query multiple SPWebs/SubSites with the new REST API (CAML query)? We’re trying to figure out if this is even possible. Thanks in advance!

    Comment by Tyler Holmes | October 4, 2014 | Reply

    • Hi Tyler, with a CAML query, you can only query one list, wether this is with the server OM or with REST. I don’t think there is another way to achieve this with REST, as you typically address one web using its URL.
      Kind regards,
      Karine

      Comment by Karine Bosch | October 5, 2014 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: