- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 01:14 AM
I have to update 3 fields on my child table if the same fields are changed on the parent. I made a business rule for the child table, but I don't know how to update the fields after query:
(function executeRule(current, previous /*null when async*/ ) {
var read_wo = new GlideRecord("x_parent_table");
read_wo.addQuery('parent_table', current.sys_id); // if the parent table and the child table belongs to each other
read_wo.query();
current.field1=
current.field2=
current.field3=
current.update();
current.setAbortAction(true);
}(current, previous);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 01:34 AM
Hi You need to write After update BR on Parent table
script:
var read_wo = new GlideRecord("childtable");
read_wo.addQuery('parent', current.sys_id); // if the parent table and the child table belongs to each other
read_wo.query();
while(read_wo.next())
{
read_wo.field1= current.field1;
read_wo.field2= current.field2;
read_wo.field3=current.field3;
read_wo.update(); //update child table
}
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 01:31 AM
Hi,
You need an After Update business rule that runs on Parent table with condtion as
Field 1 | changes
OR
Field 2 | changes
OR
Field 3 | changes
Script as below
(function executeRule(current, previous /*null when async*/ ) {
var read_wo = new GlideRecord("table_name");//replace table_name with parent table name
read_wo.addQuery('sys_id', current.parent); // replace parent with field that stores parent record on child table
read_wo.query();
while(read_wo.next())
{
current.field1=read_wo.field1;//replace field1 with correct field name
current.field2=read_wo.field2;
current.field3=read_wo.field3;
}
current.update();
}(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 01:33 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 01:34 AM
Hi You need to write After update BR on Parent table
script:
var read_wo = new GlideRecord("childtable");
read_wo.addQuery('parent', current.sys_id); // if the parent table and the child table belongs to each other
read_wo.query();
while(read_wo.next())
{
read_wo.field1= current.field1;
read_wo.field2= current.field2;
read_wo.field3=current.field3;
read_wo.update(); //update child table
}
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 01:41 AM
Hi,
Business rule should be on Parent table.
Type : After Update business rule
Condition : field1 changes OR field2 changes OR field3 changes
Script :
var gr = new GlideRecord("child_table");
gr.addQuery('parent', current.sys_id); // check if field name is 'parent' or not
gr.query();
gr.field1=current.field1;
gr.field2=current.field2;
gr.field3=current.field3;
gr.update();
Mark as correct and helpful if it solved your query.
Regards,
Sumanth