Clone Parent Records into Child #2017
Closed
SumithThota wants to merge 1 commit intoServiceNowDevProgram:mainfrom
Closed
Clone Parent Records into Child #2017SumithThota wants to merge 1 commit intoServiceNowDevProgram:mainfrom
SumithThota wants to merge 1 commit intoServiceNowDevProgram:mainfrom
Conversation
mskoddow
requested changes
Oct 11, 2025
Contributor
mskoddow
left a comment
There was a problem hiding this comment.
Thanks for your contribution! However, I don't see the added value of such a script. It's the opposite of what we want to design in ServiceNow. A data scheme with the least redundant data. Please provide a real-world use case for such a scenario to clarify its purpose!
Contributor
|
@SumithThota |
Contributor
|
@SumithThota |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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