- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 01:41 AM - edited 01-10-2023 01:51 AM
Hi All,
I have one catalog Item which takes as input an excel template with following columns
I have to Create the entry on cmdb_rel_ci table (CI Relationship) between the parent CI identified by the Parent SNow ID value with the child CI identified by the Child SNow ID value.
For this I use 1 BR to copy attachment from RITM to Data Source & then I used Transform Map simply mapping field as follows
Now it working fine only for, If I give input as Parent & Child CI Name but My Requirement Is : I want to insert excel sheet records in target table(cmdb_rel_ci) based on Parent SNow ID value & Child SNow ID value instead of Name of Parent & Child CI.
I thought I need to write Transform Map onBefore script.
Any help will be appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 03:07 AM
You don't need an onBefore script, just simply a scripted mapping. Not sure which field on the cmdb_ci table do the parent and child IDs refer to in your Excel, for the sake of an example, let's say asset_tag; then your source script would look something like this for the parent field:
var sourceField = 'u_parent_snow_id'; // change this for child field
var fieldToSearch = 'asset_tag'; // change this to the field that has your IDs
var ciGr = new GlideRecord('cmdb_ci');
ciGr.get(fieldToSearch,source.getValue(sourceField));
return ciGr.getUniqueValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 03:07 AM
You don't need an onBefore script, just simply a scripted mapping. Not sure which field on the cmdb_ci table do the parent and child IDs refer to in your Excel, for the sake of an example, let's say asset_tag; then your source script would look something like this for the parent field:
var sourceField = 'u_parent_snow_id'; // change this for child field
var fieldToSearch = 'asset_tag'; // change this to the field that has your IDs
var ciGr = new GlideRecord('cmdb_ci');
ciGr.get(fieldToSearch,source.getValue(sourceField));
return ciGr.getUniqueValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 03:27 AM
Hi @Laszlo Balla ,
Thanks for your reply!
Parent SNow ID value & Child SNow ID value not present in cmdb_ci table, It is present in Child table of cmdb_ci
kindly assist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 03:36 AM
Should be the same, just replace 'cmdb_ci' with the name of your child table, and of course update the fieldToSearch variable as needed. The returned sys_id should still work on the target reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2023 03:35 AM - edited 01-10-2023 03:35 AM