Adding a custom view to an ACL table comes in handy when you want to 1) change the order of the fields in an ACL table, or 2) view a select number of fields.
You can add a custom view manually or via script. We’ll tackle the script version first.
This post is in response to Les’ question about reordering fields in a table.
Add Custom View via Script
Let’s assume we have a table called servers1 containing 3 fields in the order shown. Note that the table is shown in the Default_View (see yellow highlight), which is the default view of every table.
You want to reorder the fields so that Install_Date is the first field shown in the table. Here’s the script to that creates a view called Custom_View, which I wrote as a standalone script.
Please note that this does NOT change the order of the fields in the actual table; it just changes the order of the fields in a view.
When you run this script, your table will look like this, based on your new Custom_View (note that the Install_Date field is listed first):
To add this code to an existing script, you would just copy lines 6-9 to your script, and change the field names and the view name.
If the existing script hasn’t opened the table yet, you’ll need to include line 5.
A few notes about the script:
- Line 3 prevents you from getting prompts when the table is updated with the custom view
- Line 5 opens the table to which you want the custom view added.
- Line 6 defines the name of the new view (Custom_View). View names cannot contain spaces.
- Lines 7-9 add the columns (fields) to the custom view
- The OK at the end of line 6 prevents you from getting prompts when you add the custom view.
- If this is the last part of your script, the custom view will be the one that is displayed. To see the Default_View, just click the Default_View tab.
When I create computed fields, I like to create a custom view called “Computed_Fields” so that I can quickly review the field values to verify that they are accurate. That way I don’t have to scroll through the table to see the computed field values.
Add Custom View Manually
Sometimes it helps to understand what a script is doing by understanding how to do it manually. Here’s how to do the same thing step-by-step.
1. Right click on the Default_View tab at the bottom of the screen (see yellow highlights) and select New.
2. Enter a name for your view and click OK. View names cannot contain spaces.
3. Select the first field you want displayed in your table, and click the right arrow to add the field to the Selected Fields box.
4. Add the remaining fields one-by-one, and click OK. Your table will look like this:
Pretty cool, huh? Let me know what you think.
Other ACL posts:
Teach Yourself ACL (most popular post on this blog)