OData - Part 4: Filtering with Parameter Values

Objective

To filter data based on a single criteria which is set at the time of the document generation in a document which filters out a list of products that need to be re-ordered.

Background Information

You often like to reorder products, but the stock you like to keep changes throughout the year. In January, business is slow and you don’t want hundreds of unused items (that will probably expire or go out of fashion), but in December, with the Christmas rush, you want to make sure you have enough to provide for every Christmas shopper that enters your store. In this tutorial we’ll teach you how to create a list that shows products to reorder based on a parameter reorder-level parameter which you only have to set when you generate the final document!

Pre-requisites

Inserting a Tag, ForEach Tag, OData - Part 1: Basic Selection, OData - Part 3: Filtering with Static Values

Starting Template

Start with a table with Product Name and Units In Stock columns, as well as a ForEach tag, some out tags and an End ForEach tag as shown below. If you have trouble creating this, check out the ForEach Tag tutorial.

Procedure

1. Add a parameter called ReorderLevel of type Integer with default of 20

Parameters in AutoTag allow you to In order to add a Parameters, click the Parameters button in the AutoTag Manager ribbon, click Add, then type a name. We used ReorderLevel. Select its type as Integer, and set a default value—we used 20. Finally, click Save to save the parameter.

Show Me How!

2. Open the OData Wizard (and resize it)

Open the OData Wizard as you have in the past—that is, select the ForEach tag and click Wizard in the AutoTag ribbon. Once it is open, you might feel like resizing it so you can see everything, especially because the filters grow a little.

Show Me How!

3. Drag Products as the root resource

Same drill as in the previous OData Wizard tutorials, you need to add a resource first, so we’ll choose Products.

Show Me How!

4. Drag ProductName, and UnitsInStock as properties

Again, same drill. So drag in the ProductName and UnitsInStock properties from Products.

Show Me How!

5. Add a filter

Now for the good stuff. Add a filter as shown in OData - Part 3: Filtering with Static Values. Click to add a group then a filter.

Show Me How!

6. Set node of filter to UnitsInStock

Again, as before in Part 3, set the node by clicking to add a node, then expanding the Products table and selecting the UnitsInStock property.

Show Me How!

7. Set condition to less than or equal to

We are checking if the Units in Stock is less than or equal to the Reorder Level, so we need to change the condition by clicking the current one, and selecting a new one.

Show Me How!

8. Set value of filter to the ReorderLevel parameter

Finally, click to set the value of the filter. As happened in Part 3, you can type a value here, or you can click the drop-down menu and all of your document’s parameters will be shown. Select the $(ReorderLevel) one.

Show Me How!

9. Close wizard and select data for out tags

Let’s finish up this document by selecting data to return to the out tags now. Close the OData Wizard if it still up, then use the usual means of selecting data for each tag: the data tree.

Show Me How!

10. Set the parameter and generate the document

Finally, we are going to generate the document just like we always do. Except this time, AutoTag will prompt you to fill in all of the parameters before the report runs. There is only one this time.

Show Me How!

Quiz Yourself!

True/False: A parameter filter means a condition where a dynamically specified property meets a specific value.
True. I just didn’t learn that in this tutorial.
False. Parameter filter means a specific property meets a dynamically specified value.
True. A parameter filter let’s me select the property when I generate a document.
False. A parameter filter just means that a parameter instead of a property is compared with some static value.
You can achieve the same effect with if and else tags and a parameter
False. If and Else tags only compare properties against other properties
True. But if you attempt that, you’ll find that it is immensely easier to simply use the wizard.
True. If and Else tags are extremely versatile, but they are meant only for programmers and technical people to use.
False. If and Else tags only compare properties against static values.
What types of comparisons can you make with a filter?
You can only compare if values are equal to each other
You can make any logical comparison to numbers such as not equal, equal, less than, greater than, or even a combination of those. They also let you make comparisons in strings and text such as starts with, ends with, contains, etc.
Almost anything, they just don’t work on strings and text.
You can only compare if values are less than, greater than, or equal to each other

Congratulations!

You have completed this tutorial. We recommend taking a look at the OData - Part 5: Complex Filters tutorial next!

close
continue