The CreatorCon Call for Content is officially open! Get started here.

Filter To-Do's In My Active Items Widget

NMeyer524
Tera Expert

Hi All,

 

We have HR Tasks, Approvals, etc that show for the user in the To-Dos widget and page. In the My Active Items widget, the tasks activity is referencing the To-Dos page and the approvals activity is referencing the Approvals page. The issue is that the number of approvals are showing in the tasks AND approvals. Is there a way to only show the number of HR Tasks only (and not include Approvals) in the Tasks Activity in the My Active Items widget? 

 

Thanks!

1 ACCEPTED SOLUTION

Rajesh_Singh
Kilo Sage

@NMeyer524 

 

Yes, you can customize the My Active Items widget to display only HR Tasks and exclude Approvals in the Tasks Activity. To do this, you need to modify the data source used by the widget. Follow these steps:

  1. In ServiceNow, navigate to Employee Center Configuration > Data Sources.
  2. Locate the data source used by the Tasks Activity in the My Active Items widget. It might be named something like "My HR Tasks" or "My To-Dos".
  3. Click on the data source record to open it.
  4. In the "Script" field, you'll find the script that fetches the tasks for the user. You need to update the script to filter out Approval tasks.
  5. Modify the script to add an additional filter condition in the GlideRecord query for the HR Task table. The additional condition should exclude HR Tasks that have a "Task type" of "Approval" or any other criteria that can uniquely identify Approval tasks. For example:
var hrTaskGr = new GlideRecord('sn_hr_core_task');
hrTaskGr.addQuery('assigned_to', gs.getUserID());
hrTaskGr.addQuery('state', 'IN', '1,2'); // Open or Work in Progress states
hrTaskGr.addQuery('task_type', '!=', 'Approval'); // Add this line to exclude Approval tasks
hrTaskGr.query();
  1. Save the data source record.

After making this change, the My Active Items widget will display the number of HR Tasks without including Approvals in the Tasks Activity count.

Note: Test your customizations in a non-production environment before implementing them in your production instance. Make sure to adapt the script to your specific HR Task table structure and field names if they differ from the example provided.

If you found my response helpful or applicable, please consider marking it as correct or helpful to assist others who may be seeking the same information.

---------------
Regards,
Rajesh Singh

View solution in original post

4 REPLIES 4

Rajesh_Singh
Kilo Sage

@NMeyer524 

 

Yes, you can customize the My Active Items widget to display only HR Tasks and exclude Approvals in the Tasks Activity. To do this, you need to modify the data source used by the widget. Follow these steps:

  1. In ServiceNow, navigate to Employee Center Configuration > Data Sources.
  2. Locate the data source used by the Tasks Activity in the My Active Items widget. It might be named something like "My HR Tasks" or "My To-Dos".
  3. Click on the data source record to open it.
  4. In the "Script" field, you'll find the script that fetches the tasks for the user. You need to update the script to filter out Approval tasks.
  5. Modify the script to add an additional filter condition in the GlideRecord query for the HR Task table. The additional condition should exclude HR Tasks that have a "Task type" of "Approval" or any other criteria that can uniquely identify Approval tasks. For example:
var hrTaskGr = new GlideRecord('sn_hr_core_task');
hrTaskGr.addQuery('assigned_to', gs.getUserID());
hrTaskGr.addQuery('state', 'IN', '1,2'); // Open or Work in Progress states
hrTaskGr.addQuery('task_type', '!=', 'Approval'); // Add this line to exclude Approval tasks
hrTaskGr.query();
  1. Save the data source record.

After making this change, the My Active Items widget will display the number of HR Tasks without including Approvals in the Tasks Activity count.

Note: Test your customizations in a non-production environment before implementing them in your production instance. Make sure to adapt the script to your specific HR Task table structure and field names if they differ from the example provided.

If you found my response helpful or applicable, please consider marking it as correct or helpful to assist others who may be seeking the same information.

---------------
Regards,
Rajesh Singh

Hello,

 

I am unsure of where Employee Center Config-->Data Sources is. The product doc directs me to Employee Center-->Activity Configuration. Once there, I am unsure how to filter to only HR Tasks. 

 

Thanks

Unable to navigate to Employee Center Configuration > Data Sources.. Could you please provide detailed steps for this.

Agree - Unable to navigate to Employee Center Configuration > Data Sources.
Can you elaborate on how to exclude approvals from the tasks list?  I added approvals as an activity configuration item so I don't want it duplicated under tasks....