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

How to access parent object within "query from" of relationship

Subhrajit2
Giga Contributor

I am trying to create a scripted defined related list on a table which will display records from different archive tables based on a field value on the parent table. I am doing something like this.

 

Apply to: a particular table
sample statement: answer = "target_table";

Query from: Scripted
Sample statement:

var table = "ar_" + parent.u_select_table.toString();//u_select_table is a field on the "target_table" which contains a table name
answer = new TableUtils(table).tableExists() == true?table:false;

 

What I am suspecting is that the parent object is not accessible within "Query from" script. So, is there a way I can populate the "query from" table dynamically based on current parent record's field value?

5 REPLIES 5

Che Pazzo
ServiceNow Employee
ServiceNow Employee

I am pulling out my hair trying to get "Apply To" to work. I keep getting an error: ReferenceError: "table_name" is not defined.

Have you tried this recently?

I get this error with something as simple as:

answer = ('cmdb_ci' == table_name);

The only way I get this to work is either:

1. set "Applies To Table" to a table

or

2. set "Apply To" to:

answer = true;