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.
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!
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.
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.
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.
Same drill as in the previous OData Wizard tutorials, you need to add a resource first, so we’ll choose Products.
Again, same drill. So drag in the ProductName and UnitsInStock properties from Products.
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.
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.
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.
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.
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.
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.
You have completed this tutorial. We recommend taking a look at the OData - Part 5: Complex Filters tutorial next!