How to access the variables of a Child form from a Parent form?

Ashirav
Tera Expert

Hi, I have a table form ABC and its child table form XYZ. I want to write a BR script on the parent table form that if there is a specific field value in the Parent table and there are specific field values in Child table form, the Parent Table form should not be updated.

I know we can dot walk to variables of parent table from the Child table using the keyword "Parent". Now how to dot walk to the Child table variables from the parent?

1 ACCEPTED SOLUTION

here is an example ... in a business rule on the parent:

var gr = new GlideRecord ('table_name'); //child table name

//get all children where the ref field is the sysid of the parent

gr.addQuery('child_table.ref_to_parent_field', current.sys_id);

gr.query();

while (gr.next()){

    these are all the children of the record you are currently on

    do what you need to do

}

View solution in original post

5 REPLIES 5

It worked, thank You!

The script I used:-

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

// Add your code here
var gr = new GlideRecord ('wm_task'); //child table name

//get all children where the ref field is the sysid of the parent
gr.addQuery('parent', current.sys_id);
gr.query();

while (gr.next()){

if(gr.u_hsse_fee == 0)
{
gs.addErrorMessage('The following mandatory field is not filled in the Work Order: HSSE Fees.');
current.setAbortAction('true');
}
}

})(current, previous);