- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2019 04:11 PM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2019 06:20 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2019 04:40 PM
I assume that you have reference field on child table which refers parent.
You will have to pass current sys_id of parent record while creating child record like below
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;
current.parent = current.sys_id;
gr.insert();
})(current, previous);
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2019 05:06 PM
Hi
Thanks for your response !
Yes I have a reference field on child table and when I manually update the reference field "result" in child table then I could see in the parent table as expected
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('result_activity');
gr.initialize();
gr.access_grant = current.result.name;
gs.addInfoMessage(gr.access_grant);
current.result= current.sys_id;
gr.insert();
})(current, previous);
I tried with both current.parent = current.sys_id and current.result = current.sys_id
it didn't work
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2019 06:10 PM
Please modify your code like below
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('result_activity');
gr.initialize();
gr.access_grant = current.result.name;
gs.addInfoMessage(gr.access_grant);
gr.result= current.sys_id;
gr.insert();
})(current, previous);
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2019 06:12 PM
Please modify your code like below
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('result_activity');
gr.initialize();
gr.access_grant = current.result.name;
gr.result= current.sys_id;
gr.insert();
gs.addInfoMessage(gr.access_grant);
})(current, previous);
Regards,
Sachin