- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 02-27-2025 03:09 PM
Hello,
Platform Analytics is changing how we've seen reporting on the last few years.
Imagine you would like to create a professional SOX (Sarbanes-Oxley) compliance dashboard to streamline reporting and risk management. While most of the components are drag-and-drop, some basic functionalities are either not well documented or not documented at all.
This guide will walk you through creating a new technical dashboard using UI Builder. Additionally, you may want to set up a default filter to personalize the user experience. Below, we will show you how to achieve that using a simple script.
Why Set a Default Filter?
Setting a default filter helps users see relevant data without manually selecting filters every time they access a page. This can improve efficiency and streamline the workflow.
Implementing the Default Filter
To set up a default filter in ServiceNow UI Builder, you can use a client script to pre-populate a filter with the current user’s information. Here’s how you can do it:
/**
* @Param {params} params
* @Param {api} params.api
* @Param {TransformApiHelpers} params.helpers
*/
function evaluateProperty({api,helpers}) {
return [{
id: api.context.session.user.sys_id,
label: api.context.session.user.fullName
}];
}
Explanation of the Code
The function evaluateProperty is used to determine the default filter values.
api.context.session.user.sys_id fetches the logged-in user’s unique system ID.
api.context.session.user.fullName retrieves the full name of the current user.
The function returns an array containing an object with id and label, which can be used as the default filter in UI Builder.
Applying the Script in UI Builder
1. Open UI Builder in your ServiceNow instance.
2. Select the page or dashboard where you want to apply the default filter.
3. Locate the component where filtering is required (e.g., a data table or list component).
4. Use the data binding feature to assign the script to the default filter property.
5. Save and test the changes to ensure the default filter is applied correctly.
Conclusion
By implementing this script, you can dynamically set up a default filter in UI Builder, ensuring a more user-friendly experience. This approach is particularly useful for customizing dashboards and reports based on the logged-in user. If you have any questions or need further customization, feel free to reach out!
#PlatformAnalytics #GRC