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

Dynamic Filter Query in Scoped App

nwilliam
Tera Contributor

When I try to make a GlideRecord or GlideAggregate against the "One of My Assignments" Dynamic filters in my scoped app I get the error: 

Script execution error: Script Identifier: unknown, Error Description: "getMyAssignments" is not defined., Script ES Level: 200
Evaluator: com.glide.script.RhinoEcmaError: "getMyAssignments" is not defined. script : Line(1) column(0) ==> 1: getMyAssignments()


Here is my script I am simply running as a background script for now:

var ga = new GlideRecord('my_custom_app_table');
ga.addEncodedQuery('active=true^assigned_toDYNAMIC0f63961e5f510100a9ad2572f2b47745');
// ga.addAggregate('COUNT');
ga.query();
while(ga.next()){
    gs.info(ga.getDisplayValue());
}

The dynamic filter works when applied to a list...but not when I run it in a script.  Also this works when I run it in a global scope...but I'm not understanding why I couldn't run in scoped.

Additionally I went to this record in sys_filter_option_dynamic and set the role to one of my custom app roles and then went to the "getMyApprovals" business rule that is its "Reference Script" and set it to Allow all application scopes....and I get a slightly different error (from allowing app scopes):

Script execution error: Script Identifier: unknown, Error Description: getMyAssignments undefined, maybe missing global qualifier, Script ES Level: 200


I just want to be able to utilize a dynamic filter in a scoped application script...in particular I want to see assigned to me or my delegates in a list and be able to run a glide aggregate against that same filter to determine the total count.

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@nwilliam 

seems scope issue

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

IamAmolB
Tera Guru

Hi @nwilliam ,

 

You may try the below script,

new global.<script include name>().getMyAssignments() or your new scopename(where the script is written).<script include name>().getMyAssignments() and that might work for you.

 

Let me know if that help to you. and please mark it correct if you find this as a solution

 

Regards,

Amol Bavaskar

But I'm not running the script include directly..Its running because I'm adding this as an encoded query to a glide record/aggregate:

'active=true^assigned_toDYNAMIC0f63961e5f510100a9ad2572f2b47745'

Where the dynamic part is the "one of my assignments" dynamic filters.