How to get parent table field value in child table field ?

Nivetha K
Kilo Contributor

Hi All,

I've a record producer ("Request firewall Access") in scoped application "Firewall Audits" which will create a FTASK in a custom table (firewall_new_request). I've a MRVS in this record producer, on submitting a request from this record producer, all the rows which we're adding in MRVS will be available under parent table FTASK related list. 

We've created another table (Rule resource data) to store all the MRVS values and we're setting the parent field of this child table from record producer script.

"""""" ruleresource.parent = current.sys_id.toString(); """""""

Query: I've a field called "Name" (String) in my record producer. After submitting the request from that record producer, I wanted to see the value which user entered in "Name" in child table (Rule Resource data) list view. 

I wrote below before BR in child table by checking insert and update checkbox, but it is not working.

(function executeRule(current, previous /*null when async*/) {

var gr = new GlideRecord('sn_disco_firewall_new_firewall_request');
gr.addQuery('sys_id', current.parent);
gr.query();
if(gr.next()){
current.u_name = gr.u_name ;
current.update();
}

"u_name" is the backend field value for 'Name' in both parent and child table.

can anyone please some way to get the 'Name' value from parent table to child table 'name' field?

Note: Both tables extended from Task table.

Parent table field value:

find_real_file.png

Child Table field value is empty:

find_real_file.png

Please suggest a way to get the field value on child from parent.

 

 

1 ACCEPTED SOLUTION

Hi,

is that field in same scope as that of table?

try this

current.u_name = current.parent.variables.u_name;

Regards
Ankur

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

View solution in original post

20 REPLIES 20

Nivetha K
Kilo Contributor

@Ankur Bawiskar  ---- Would you be able to help on this please, if possible ?

Hi,

are you sure both the field names are correct?

if the table "sn_disco_firewall_new_firewall_request" extends task then don't keep same u_name field on it.

Change the name and then test once.

Regards
Ankur

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

Hi Ankur,

I changed my record producer backend 'name' variable to u_name_rp and tried executing the BR.

My log line is getting printed but name field is not getting updated in my child table.

find_real_file.png

Hi,

okay you want variable value then do this

current.u_name = current.parent.variables.u_name_rp;

Regards
Ankur

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

Hi Ankur,

Tried the above mentioned change in my BR, still not sure why its not working.

I've attached both tables Name field as well as updated Br. Pleasee check and help if possible.

New Firewall Request (Parent table):

find_real_file.png

Firewall Rule Resource Data (child table):

find_real_file.png

BR:

Before BR, Insert and update box checked. No condition in when to run.

find_real_file.png

Please help to achieve this !