4.6.2 VPM Conditions
You can add a condition to a VPM to filter the rows retrieved from the database tables. To add a condition to an existing VPM, follow these steps:
1. Open the Asset panel, and expand the 'Data Source' node.
2. Expand the data source that contains the VPM you want to edit. Double-click the VPM to open it for editing.
3. In the VPM edit view, click the Conditions tab at the bottom of the window.
4. In the 'Define Conditions' pane, click the 'New' button. This opens the 'New Condition' dialog box.
Previously defined conditions are listed in alphabetical order. (case insensitive).
5. Enter a name for the new condition in the 'New Condition' dialog box, and click 'OK'.
6. In the 'Define Conditions' pane, click the 'Choose Table' button. This opens the 'Select Table' dialog box, showing a list of database tables.
The dialog box provides controls for searching and sorting tables. See Adding Database Tables to the Physical View for details.
7. To define the condition on an individual table, select the 'All' option at the top. Select the desired database table from the list, and click 'Finish' to close the dialog box.

The filter condition can be based on any fields in the selected table, and the filter will be applied whenever the selected table appears in a query.
8. To define the condition on a physical view, select the 'Physical View' option at the top. Select the desired physical view from the list, and click 'Finish' to close the dialog box.

Note: If you have created one or more aliases of a table in the physical view, do not apply VPM conditions to the original table. (VPM conditions applied to the original table may affect its aliases in an unpredictable manner.) Rather, apply VPM conditions only to the aliased copies.
For the 'Physical View' option, the filter condition can be based on fields from any table in the physical view. These fields will be automatically included in any query generated from the physical view, even if the query does not explicitly include them. This effectively applies the filter globally to all data models derived from the physical view.
9. In the 'Conditions' panel of the Conditions tab, specify the condition that you want to apply to the table.
The menu controls for specifying the condition are the same as those used in query construction and data binding. See Filtering Data in Data Binding Wizard in Report Design for an example of constructing a condition. The arrow menu allows you to use different kinds of values in the right-side of the condition.

You can also use two special variables, _USER_ and _ROLES_, as parameters in the VPM condition to represent the current user user's roles.
'Field' allows you to select a different column from the same table or physical view. 'Expression' allows you to enter a regular expression using Perl5 regex syntax (see Appendix A.5, Regular Expressions.) 'Value' allows you to enter a fixed value. 'Subquery' allows you to specify a distinct query to return the right-side of the condition. 'Session data' provides the logged-in user's name, an array of user roles, and an array of user groups.
10. Click 'Append' to add the condition clause. Repeat the above steps to add additional clauses, as needed.
11. Click 'Save' in the Style Studio toolbar to save the changes to the VPM.
Once a condition is added to the table or physical view, the selected table or physical view is automatically listed in the Lookup tab. This indicates that the VPM will be applied to any query that contains the selected table, or any data model that uses the physical view.
Figure 1. VPM Conditions

| << 4.6.1 Creating a VPM | © 1996-2013 InetSoft Technology Corporation (v11.4) | 4.6.3 VPM Hidden Columns >> |