- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 12:29 AM
hello,
i want to write a businees rule i have created mrvs in record producer
when i add rows then its child record must also be created in mrvs , how can i achieve this?
how to link child to parent in business rule
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 12:39 AM
Hi @alishamulan ,
you can use below sample script to link child to parent in BR.
This script ensures that each child record is linked to its parent record whenever the parent record is inserted or updated.
If my response helped, please mark it correct/helpful and close the thread so that it benefits future readers.
Regards,
Mohd Arbaz.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 12:39 AM
Hi @alishamulan ,
you can use below sample script to link child to parent in BR.
This script ensures that each child record is linked to its parent record whenever the parent record is inserted or updated.
If my response helped, please mark it correct/helpful and close the thread so that it benefits future readers.
Regards,
Mohd Arbaz.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 12:41 AM
HI @alishamulan ,
To achieve this in a Business Rule when using MRVs in a Record Producer, follow these steps:
Create the Business Rule:
Table: Set the Business Rule to trigger on the Record Producer's table (e.g., sc_cat_item).
When: Choose "After Insert" to trigger after the record is created.
Link Child Record to Parent:
Inside the Business Rule, use GlideRecord to create the child records in the related MRV table.
Link the child record to the parent using the parent record's Sys ID.
(function executeRule(current, previous /*null when async*/) {
// Assuming 'mrvs' is the field holding MRV values in the Record Producer
var mrvs = current.mrvs; // Access MRV variable from the record producer
// Iterate through the MRV entries
for (var i = 0; i < mrvs.length; i++) {
var childRecord = new GlideRecord('your_child_table');
childRecord.initialize();
childRecord.parent_field = current.sys_id; // Link child to parent
childRecord.child_field = mrvs[i].value; // Set your MRV value
childRecord.insert(); // Insert child record
}
})(current, previous);
Steps:
Replace your_child_table with the actual table for child records.
Replace parent_field with the field that links the child record to the parent (sys_id of the parent).
Replace child_field with the field to store the MRV value.
This will create the child records in the MRV table, linking them to the parent record.
If my response was helpful, please mark it as the correct answer and close the thread. This will help others who come across the same issue.
Thanks!
Gaurav Rathaur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 12:55 AM
you can use record producer script if you are showing MRVS on record producer or after insert business rule
check this link and enhance
How to create records in a table from MRVS?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 12:55 AM
Seems you created thread for this already and response was already given to that
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader