Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Report Includes Parent Assignment Groups Even When User Isn’t a Member

TomDickson
Tera Contributor

I have a report on a Platform Analytics dashboard to list all SCTASKS assigned to groups the logged in user is a member of.

  • Data Source: Catalog Task
  • Custom Conditions
    • Active = true
    • Assignment group is (dynamic) 'One of My Groups'


This choice of dynamic filter unfortunately includes parent assignment groups which (in most cases) the user is not directly assigned to. I do not want to include the parent unless they are directly a member of it. 

 

What I've tried so far:

  • Dynamic Filter Option with Custom Script. 
    Result: Fails due to sandbox restrictions — Illegal use of while loop and Invalid function definition.
    Even single-line or callback versions trigger sandbox policy violations in the current Yokohama release.
  • Script Include + Dynamic Filter
    Created a Script Include to query sys_user_grmember and return a list of group sys_ids, then called it from the dynamic filter.
    Result: Script runs fine in Background Scripts (returns valid sys_ids) but returns zero results in the report.

I've tried creating a couple of other test Dynamic Filters by have not succeeded. Am I over complicating the method to get this working?

 

Any suggestions would be appreciated on how to get this working the way I need it.

 

Instance: Yokohama Patch 6 Hotfix 2

1 ACCEPTED SOLUTION

@TomDickson 

So you can use GlideRecord and fetch the correct records to which the logged in user belongs w.r.t. group by querying sys_user_grmember and then query sc_task

Example:  it worked fine for me. Please enhance it from your team

AnkurBawiskar_0-1760332057547.png

 

AnkurBawiskar_1-1760332081818.png

Output: I passed 2 sysIds from script include and Report shows 2 records correctly

AnkurBawiskar_2-1760332137856.png

 

💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Bhuvan
Giga Patron

@TomDickson 

 

Please try using below logic

 

https://www.servicenow.com/community/developer-forum/dynamic-filter-option-exclude-parent-groups/m-p...

 

If this helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan

Ankur Bawiskar
Tera Patron
Tera Patron

@TomDickson 

I believe Dynamic filter doesn't work in report filter condition.

Did you try to check if script include can be called there?

Something like this

-> script include is client callable

-> script include is class less

AnkurBawiskar_0-1760330649118.png

 

AnkurBawiskar_1-1760330670524.png

 

💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@TomDickson 

So you can use GlideRecord and fetch the correct records to which the logged in user belongs w.r.t. group by querying sys_user_grmember and then query sc_task

Example:  it worked fine for me. Please enhance it from your team

AnkurBawiskar_0-1760332057547.png

 

AnkurBawiskar_1-1760332081818.png

Output: I passed 2 sysIds from script include and Report shows 2 records correctly

AnkurBawiskar_2-1760332137856.png

 

💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you for your response, I have created a script includes, then changed the filter to Assignment Group> SysID is one of javascript:getGroupsReport().
This has removed the parent assignment group from the results.