How to call script include in a module url argument to get dynamic delegated users?

ChuanYanF
Tera Guru

Dear experts,

 

I have created a script include which is DelegationUtil, which helps to check is the user a delegate of the owner. And I want to create a module list view for them, and this is how defined the URL arguments but currently is not working. How can I approach this issue?

/sn_compliance_control_list.do?sysparm_fixed_query=owner=javascript:gs.getUserID(),(new global.DelegationUtil().isUserOrDelegate(current.owner))^state=draft,review^u_testing_procedureISNOTEMPTY
9 REPLIES 9

YaswanthKurre
Giga Guru

Hi @ChuanYanF ,

 

It looks like you're trying to create a filtered list view in ServiceNow using a custom script include (DelegationUtil) to determine if the current user is either the owner or a delegate. However, the issue lies in how you're trying to use JavaScript directly in the URL query, which ServiceNow does not support in that context.

 

Create a Dynamic Filter Option

You can create a dynamic filter option like "My Delegated Controls" and use your DelegationUtil logic in the script for that filter and call this filter directly from your module.

 

Mark this as helpful and correct if this helps.

 

Thanks,

yaswanth

 

 

 

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@ChuanYanF 

you can check lot of OOTB modules where script include is called and uses URL from arguments

Did you check those?

what does your script include function return?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Ankur Bawiskar
Tera Patron
Tera Patron

@ChuanYanF 

you can also use List of Records Link type and use script include

See this OOTB module for "My Approvals"

AnkurBawiskar_0-1749529684918.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

I tried using the same approach calling my script include like this below, Owner is javascript: global.DelegationUtil().isUserOrDelegate(), but it still does not work, Owner = (empty)

ChuanYanF_0-1749533389781.png