Auto create child record when record inserted on parent table - Related list (BR)

Service Manager
Kilo Guru

HI All,

I need help to auto create the record in related list when record is inserted on Parent table

BR on after on Insert is being created on parent table "abc" and child table is "xyz".However the records is getting created on child table on insert of record on parent table "abc"  but unfortunately we cannot link in related list 

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

// Add your code here
var nr = new GlideRecord('result_activity');
gr.initialize();
gr.access = current.result.system_application.u_name;
current.access = current.result.name;

gr.insert();

})(current, previous);

Thanks

1 ACCEPTED SOLUTION

This is what i understood from your requirement.

You have parent table A and child tables B and C.

You configured related list on form A and related list is pointing to table B.

You need to have reference or system relationships to maintain relationship between table A and B.

 

But, you stated that your reference to table A is in table C.

You need to write business rule on table C to push table A reference to table B. This should resolve your issue.

 

Regards,

Sachin

 

View solution in original post

8 REPLIES 8

I appreciate your quick response!

it's weird 
I could see the value under the field in List view but not on form view of child table

but again on insert of parent records child records are being getting created but does not appear in related list.

I have to manually update the child record to view under parent record related list 

 

Thanks

Hi 

It worked on new table 
I tried with different table and record got created in child 

but the thing is here little confusing 

We do not have reference field on child table which refers parent

It is referring to third table via reference field, thus we need to bring record from third table in child table

can we add encoded-query to filter out based on name of child?

THanks

This is what i understood from your requirement.

You have parent table A and child tables B and C.

You configured related list on form A and related list is pointing to table B.

You need to have reference or system relationships to maintain relationship between table A and B.

 

But, you stated that your reference to table A is in table C.

You need to write business rule on table C to push table A reference to table B. This should resolve your issue.

 

Regards,

Sachin

 

Service_RNow
Mega Sage

Hi,


You can create an AFTER business rule on Action Table with filter condition as state | Changes to | In Progress with the script as


var gr = new GlideRecord('PASS PRIVATE TASK TABLE NAME HERE');


gr.initialize();


gr.parent = current.sys_id; //Assuming parent is the column name If this is a custom field then it should be u_parent


gr.insert();

Check this website. Maybe you will find some interesting information.

Click Here

Please mark reply as Helpful/Correct, if applicable. Thanks!