Get sys_id for relation in cmdb_rel_ci

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2018 01:11 PM
I'm creating a web service where I enable the end user to submit a parent & child UUID in order to mange CI relations to other CIs.
I have added a custom filed in cmdb_ci table called u_uuid, so that I in cmdb_rel_ci can manage (delete and create) records in the table...
But I think I need a bit of help to get started in the script.
The web service is using a transform map with the flelds called u_uuid_parent and u_uuid_child.
What I'm looking to do is this:
- Get sys_id for row in cmdb_rel_ci based on input from webservice using u_uuid_child
- Remove that row
- Create a new relation based on u_uuid_parent and u_uuid_child
Fig. 01 - Screen dump from field mapping
I'm assuming this will all go into a transform script that I have related to my web service.
But as I said, I think I need a bit of help to get started.
Kind regards
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2018 11:49 PM
Anyone with input?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2018 11:55 PM
Hi Henrik,
So you basically want to update the parent field of that row? If that is it, then you can simply map it using field mapping having the u_uuid_child field as coalesce value and the parent field being mapped to your u_uuid_parent
Thanks,
Kannan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2018 12:48 AM
Hello Kannan and thanks for the post!
What I'm looking to do is this:
- Get sys_id for the row in cmdb_rel_ci based on input from webservice using u_uuid_child.
- Remove that row
- Create a new row in cmdb_rel_ci based on u_uuid_parent and u_uuid_child
I guess this should be done in a script running during the transform map.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2018 01:04 AM
Hi Henrik,
By row i think you mean record, incoming import set data will come in rows but data already in a table on SN is a record.
Will there only be one relationship set up for each u_uuid_child? If so then Kannan's solution is correct, you can coalesce on the u_uuid_child and it will replace the parent with whatever data you are importing.
If a u_uuid_child will have more than one relationship then you need a way to identify the specific relationship record you want to amend.