
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 01-06-2021 09:52 PM
Default Value for Cascading filters
Recently, I had a challenge where I have to apply default values for Cascading filters. Unlike the interactive filters, there is no option to apply default values for this.
The cascading filter values are stored in this table - sys_canvas_preferences. First I created my preference which has to be set as the default value. A record got created in the canvas preferences table, there is a user field in the canvas record, I just updated the user value to a different user. Then I Impersonated the user and navigated to the dashboard and it worked perfectly, the cascading filter had the value populated for the user.
I used the same logic to create canvas records for few users. The values in the preference table can be pretty tricky to apply so I used the template option to create records.
I created a template [sys_template] with all the values drawn from my preference record except the user field. Finally used a simple glide record query in the background script to create records for users.
sys_template record
GlideRecord Query
var grSysUser = new GlideRecord('sys_user');
grSysUser.addEncodedQuery("department=a581ab703710200044e0bfc8bcbe5de8");//only finance dept
grSysUser.query();
while (grSysUser.next()) {
var canvas = new GlideRecord('sys_canvas_preferences'); // default filter record table
canvas.initialize();
canvas.applyTemplate("canvas template"); // created template form default value
canvas.user = grSysUser.getUniqueValue();
canvas.insert();
}
Stay safe, stay healthy!
Thanks!
Murali
- 1,128 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi
Thanks for sharing this article. Could you please elaborate the process.
I have a record in sys_canvas_preferences table (upon creation of cascading filter) and created a template in sys_template how the template will interact with canvas in my case it is not working.
Please advice on this.
Requirement: I want to set the default value in the cascading filter level - 1

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Sangeetha,
1. sys_canvas_preferences is created when you apply cascasing filter in the dashboard.
2. create a template out of it
3. run the above script in BG, fill the template name and encoded query.
Thanks