- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hello,
I have a dashboard where I want to add a data visualization that shows the trend of new cases assigned to the currently logged-in user.
I already have an indicator that counts the cases created today, and I set this indicator as the data source for the data visualization.
My issue is how to filter the data to show only the cases assigned to the logged-in user.
When I try to add an additional condition to the indicator—such as "Assigned to is dynamic me"—it doesn’t work because when the job takes the screenshot, it runs under the job user context, not the logged-in user.
I also tried using a dynamic filter in the dashboard. The filter has as filter source the table sys_user and the filter condition is sys_id is javascript:gs.getUserID().
The filter correctly shows the logged-in user as an available value, but the problem is that when the user accesses the dashboard, the filter is empty by default and not pre-filled with the user.
As a result, when the user opens the dashboard, the report shows all cases instead of just those assigned to them.
Is there a way to have the trend display only the cases assigned to the logged-in user by default?
Thank you very much for your help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
You can use a client script to set the filter's value to the user's sys_id. You can attach this client script to the page loaded event, so that the page loading triggers the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @valesky ,
1. Use a Breakdown with a Scripted Breakdown Source
Create a scripted breakdown source that dynamically returns the logged-in user's sys_id.
(function() {
var breakdownValues = [];
var userID = gs.getUserID();
breakdownValues.push(userID);
return breakdownValues;
})();
Then use this breakdown in your indicator and data visualization. This ensures the data is filtered based on the logged-in user, regardless of the job context.
2. Use a Scripted Filter in the Indicator
Instead of relying on dashboard filters, modify the indicator’s condition using a scripted filter:
assigned_to = javascript:gs.getUserID();
This works well for interactive dashboards, but may still show all data during scheduled jobs unless the job is run in the correct user context.
3. Use a User-Specific Dashboard Clone
If the above options don’t meet your needs, consider creating user-specific dashboard views using dashboard permissions and filters, though this is more manual and less scalable.
If my response helped, please hit the 👍Thumb Icon and accept the solution so that it benefits future readers.
Regards,
Pratik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Hello, thanls for your answer.
How can i create a scripted filter to add in the dashboard?
I see only the possibility to ad filter without script.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago - last edited 2 weeks ago
The previous solution was probably written by ChatGPT as that is not how breakdowns work.
You have 2 important points:
1. Record data (case & user) - At the time of data collection, you have to record for which user the case was assigned. A breakdown mapped to the "assigned to" field achieves this without any scripting.
2. Dynamic filtering - when a user views the visualization, they should only see the data for cases that they were assigned. This would require the breakdown element of the current user being applied. You went in the right direction, but the filter value is not applied by default.
You can try to apply the filter choice by default using user preferences, or you can create a Technical Dashboard (as opposed to an Inline one) and configure the filter (or straight away the visualization) to have the value of the currently logged in user's sys_id as the breakdown element.
Ps: I am not sure your use case actually requires PA. I would create a metric definition that records the first assignee of cases, make a database view connecting cases with metrics, then do a simple report (visualization) on this database view and map the filter to the metric_instance.field_value instead of messing around with breakdowns.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Thanks for your answer.
Following your suggestion i made a technical dasboard and I created the data visualization. I added a filter, but it is the same of the one of on line dahsboard, and it is not possible to put the dyamic logged in user as default.
Is there something I'm doing wrong?
