Transform map script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2023 06:09 AM
Hi
I don't understand this one "Any GlideRecord's insert calls should be written in "after" transform map script as inserting into reference/target tables" please provide me any example?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2023 06:30 AM
Hello @shivaadapa ,
Please check out this link
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2023 06:39 AM
Hi @shivaadapa ,
var cluster = source.u_cluster;
var cgr = new GlideRecord('cmdb_ci_cluster');
cgr.addQuery('name', cluster);
cgr.query();
while (cgr.next()) {
var rgr = new GlideRecord('cmdb_rel_ci');
rgr.initialize();
rgr.parent = cgr.sys_id;
rgr.child.setDisplayValue(source.u_name);
rgr.type.setDisplayValue("Hosted on::Hosts");
rgr.insert();
}
The script goes through each cluster record, and for each cluster, it creates a relationship record that indicates the source CI is hosted on that cluster. The relationship is established using the 'Hosted on::Hosts' type.
It perform additional processing or customization after a record has been transformed and inserted into the target table.
The "onafter" script allows you to perform actions that depend on the record being present in the target table.
In this case, it checks if there's a related task and updates it. This is something you typically do after the record has been inserted.
Mark it helpful and solution proposed if it serves your purpose.
Thanks,
Anand