Calling Script Include from Module Filter

ashish_rai
Kilo Contributor

Hi All,

I am trying to call a script include from module filter using -

javascript:AZChangehelper.getCompanyID()

Script include is client callable and function is returning sys_id of some group. Is it mandatory to have same function name as script include or is there any other way to call script include from module filter.

tried these many options-

javascript:AZChangehelper.getCompanyID()

javascript:gs.inlcude('AZChangehelper'); new AZChangehelper.getCompanyID()

javascript:getCompanyID()

Nothing is working.

Thanks,

ARS

11 REPLIES 11

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I would use the is (dynamic) option and then create a scripted filter there.



Using Filters and Breadcrumbs - ServiceNow Wiki


Scripted Filters


Hi Brad,



I tried creating Dynamic filter by taking reference from existing "One of my functional groups". But still I am getting empty value in my filter. My filter is on change_request table and I have a field Cab Unit which is a reference to Group table.


In my filter I am doing -


Cab Unit is (dynamic) getCompany, where getCompany is my dynamic filter.


PFA image for dynamic filter definitiion.


dynamicfilter.PNG


Filter image -   Cab Unit is empty


emptz value.PNG


ashish_rai
Kilo Contributor

I tried creating scripted filter by having same function name as script include(client callable). Even the first line of script include is not getting called from the filter.


In System logs, there are some warnings which are generated:


org.mozilla.javascript.EcmaError: "__ref__" is not defined.
  Caused by error in <refname> at line 1

==> 1: __ref__.getReferenceKey()


------------------------------------------------------------------------------------


org.mozilla.javascript.EcmaError: "__ref__" is not defined.
  Caused by error in <refname> at line -1



Any help would be appreciated.



Thanks,


ARS


Can you share the script include you have written and the scripted filter ?



Thanks,


Mihir