Create a new record in child table based on a field in parent table - can we achieve it through BR. Please suggest

Madhurima6
Tera Expert

BR to Create a new record in child table based on a field in parent table?

 

 

Thanks in Advance.

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

Hello ,

yes you can do it though a after update BR on parent table 

where you condition can be like state changes (Example)

You can specify your condition and in script you can insert a record in child table 

var gr = new GlideRecord('your_child_table_name');

gr.initialize();

gr.field_holding_parent_record = current.sys_id;

gr.insert();

Some thing like this you can do 

Hope this helps 

Mark my answer correct if this helps you

 

View solution in original post

8 REPLIES 8

Pavankumar_1
Mega Patron

Hi,

Refer refer below links so you can do it with the Business rule with the conditions as per your business.

 

https://community.servicenow.com/community?id=community_question&sys_id=b48943a5db5cdbc01dcaf3231f9619aa

https://community.servicenow.com/community?id=community_question&sys_id=7f805369dbdcdbc01dcaf3231f9619c9

 

Thanks,

Pavankumar

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Pavankumar_1
Mega Patron

Hi,

You can use if condition it will run only once

after your query add something like below

var inc= new GlideRecord('table_name');
    inc.addQuery(); //add your query here

if (inc.next())
    {
        inc.initialize();
        inc.parent_incident = current.sys_id;
        inc.category = current.category;
        inc.insert();
    }

 

 

 

Thanks,

Pavankumar

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

it should be simple enough

BR: After update on Parent Table

Condition: Your Field Changes

Script:

// create record into child table

What did you start and what's not working?

Regards
Ankur

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

Urmila Mane
Tera Contributor

You can use after insert BR on parent table

write code

var gr=new GlideRecord('child_table')

if(gr.next()){

    gr.initialize()

    gr.category=current.category;

   gr.insert()

}

If it is helpful then click on helpful

Thanks & regards,

Urmila Mane