Working with 3 or more CAML Conditions
The background for this blog post comes in light of a recent customer case. They were trying to create a metric that required 3 or more CAML conditions to be put in place. They were having an issue with formatting in the sense of nesting within the formula. They were unfamiliar with the setup of creating multiple CAML conditions for a metric. It really all boils down to the conditioner rules that you put into place.
When working with CAML conditions in queries it may be quite daunting if you are unfamiliar with the syntax. You must think of the various caveats that need to be taken into consideration; Is the syntax correct? Is the field type a Boolean (yes/no) or Text type? Etc.
The example for this particular use case will be the Overdue Tasks metric that will encapsulate conditions not to include completed items, have a due date later than today and not include summary tasks. I have colour coded the CAML conditions to make it easier to understand the setup.
<FieldRef Name=”Status” />
<FieldRef Name=”DueDate” />
<Value Type=”DateTime”><Today /></Value>
<FieldRef Name=”bwSummaryTask” />
You can add the above code to the CAML conditions editor in the Metric settings should you wish to create and track this metric too.
And if you really want to get underneath the hood, the CAML conditions can also be incorporated into the Report Definitions too.
You may also be interested in applying 4 or more conditions to a particular CAML query. You can definitely use the above nesting format. If you’d like to go deeper with potentially even 4 or more, here is a link to a StackExchange blog post that may help, as well.
If you are interested in learning more about CAML conditions and other ways to incorporate into your project management solution, my colleague Ciara has written some blogs to help get you started.