Clone Parent Records into Child #2017
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description:
Copies records from a parent table into a child table in ServiceNow, optionally preserving the parent
sys_idas a reference on the child.Purpose
Provide a simple example that shows how to iterate parent records (GlideRecord), map selected fields, create child records, and optionally keep a parent reference, useful as a Scripts - Background snippet or a starting point for a Script Include / scheduled job.
Behavior (high level)
x_parent_tableusingaddQuery('your Query')andquery()x_child_table.short_description,descriptionfrom parent to child.childGR.parent = parentGR.sys_idto retain a link to the parent.gs.info().Contract (inputs / outputs)
Inputs:
addQueryor encoded queryOutputs:
gs.info()Proof
I have attached a screenshot which shows a child table (u_child_Incs) having copies Parent table (incident) records.
Please do check it once
Pull Request Checklist
Overview
Code Quality
Repository Structure Compliance
Core ServiceNow APIs/Server-Side Components/Client-Side Components/Modern Development/Integration/Specialized Areas/Documentation
Restrictions