Use query options

The GetValue and ValidateEntities activity effects have a QueryOptions parameter that allows you to use OData query options, for example, calculate sums.

You can use the following OData clauses in the query options.

Query option Examples of use

$top

Set a maximum limit of results retrieved by the specified query. For example, get the first case that matches the filter $top=1 or the top five cases $top=5.

$skip

Skips a selection of results based on a specific number. For example, $skip=3 bypasses the first three results.

$count:

Counts the number of results in the specified property. You can, for example, use the count value in different guards or other rule sets provided by DCR.

Note that count is equal to sum.

$orderby:

Sorts results in ascending order. Use together with $top, for example to get the newest entity $orderby=ID $top=1.

$orderbydesc:

Sorts results in descending order. Use together with $top, for example. if you want to get the last row in a query $orderbydesc=ID $top=1.

$aggregate

Summarizes values and writes the sum to another field. Here an example could be a case with a custom type where the custom type contains an amount of money. If you want to display the sum of the amounts in a field on a case, you can use a GetValue activity effect with a filter $count?aggregate=Sum(Amount_Value)$ignorecount=true.

You can apply the following aggregations:

  • Avg

  • CountDistinct

  • Max

  • Median

  • Min

  • Stddev

  • Variance

Note: You can combine top, skip, and orderby, but not count and aggregate.

See examples of query options in DCR Portal.