Ref qualifier dictionary entry + parent tables

Alex240
Giga Expert

Hello community!

I've got a custom table with a reference to Table (sys_db_object) and a reference to Field (sys_dictionary).

The reference to Field (sys_dictionary) has a ref. qualifier like: 

javascript:"active=true^name="+current.u_table.name.getValue()

It works fine for fields belonging directly to the table but it fails when the table is a child table and filter does not return the fields belonging to parent table.

Does anyone know how can I apply a ref. qualifier fetching all the fields?

 

Thanks in advance!

Cheers,

Alex

1 ACCEPTED SOLUTION

Solution:

Array(new TableUtils(current.u_table.name.getValue()).getHierarchy()).toString().replace("[", "").replace("]", "");

View solution in original post

7 REPLIES 7

Maik Skoddow
Tera Patron
Tera Patron

Hi

you can use the TableUtils API to fetch all parent tables in a list: https://developer.servicenow.com/dev.do#!/reference/api/sandiego/server_legacy/c_TableUtilsAPI#r_TU-...

And build a ref qualifier like this

javascript:"active=true^nameIN" + new TableUtils(current.u_table.name.getValue()).getHierarchy()

Kind regards
Maik

Hey Mike!

Thanks for your answer. It looks like not working because of the type of data returned by the method .getHierarchy()

It returns something like "[table_a, table_B]" but query would work with something like ["table_a", "table_b"]. Do you know any solution for it?

 

Cheers,

Alex

Solution:

Array(new TableUtils(current.u_table.name.getValue()).getHierarchy()).toString().replace("[", "").replace("]", "");

Hi

just remembered the problem with returned java objects instead javascript objects

So the best and recommended approach is using j2js.

The example for exact your situation is given at https://developer.servicenow.com/dev.do#!/reference/api/quebec/server_legacy/r_J2js-j2js_O

That way, there is no need for string replacements.

Kind regards
Maik