Remove CI Relationship in IH ETL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2022 09:47 AM
We are getting a delta file from on of internal partner and need to remove CI Relationship is there a way in Integration Hub ETL to remove CI Relationships?
- Labels:
-
IntegrationHub
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2022 06:36 PM
This is a real problem for us too and wasn't able to find a solution yet.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2023 03:08 AM
Hi,
Ran into your post while experiencing a similar demand; an existing IntegrationHub ETL transform map was only adding new relationships, not even overwriting existing ones.
From what I could determine this seems the way it is, only inserts as you stated.
However, in case you are still searching for a potential work-around, please consider the following I've been able to successfully setup. Our use case was a server import job would have to be updated accordingly to the correct service offering. Before our action it would simply keep adding relationships, never updating.
So to resolve this I've added an After Transform script on the CMDB Integration Studio Application Data Source (alternatively: System Import Sets > Robust Import Set Transformers > Select the one you need to edit and open the Transformer Definition). Mark the "Execute After Script" en provide a script which does what you need, our example below:
(function(ireOutput, ireInput, runId) {
for (var i = 0; i < ireOutput.length; i++) {
var output = ireOutput[i];
var items = output.items;
for (var j = 0; j < items.length; j++) {
// check if relations exist for this server we just added
if (items[j].className == 'cmdb_ci_server') {
var serverId = items[j].sysId;
var relationGR = new GlideRecord('cmdb_rel_ci');
relationGR.addQuery('child', serverId);
relationGR.orderBy('sys_created_on');
relationGR.query();
var rowCount = relationGR.getRowCount();
// If we found more than one record, multiple relationships exist; delete (all) but the oldest, but leave the last one
while (rowCount != 1 && relationGR.hasNext()) {
if (relationGR.next())
relationGR.deleteRecord();
rowCount -= 1;
}
}
}
}
})(ireOutput, ireInput, runId);
Hope this helps you out still.
Regards,
Guus