Service Desk Practitioners Forum
cancel

How to remove CI relations using sd_event?

Highlighted
Jan Gunnar Helg
Honored Contributor.

How to remove CI relations using sd_event?

Hi

Can I use sd_event with Delete option to remove all CI relations from a specific CI?

If so, how?
7 REPLIES
Sam decosta
Outstanding Contributor.

Re: How to remove CI relations using sd_event?

Hi Jan,

I am not sure how to do this with SD event but i have done this in my organization with the help of VB script.

You need to create a DB rule
1). Give condition when you want to delete relation.
2). Create a script and using sql query, you can remove relation from CI.
3). Execute the Script in the Action part of DB rule.

Please don't forget to assign the points.

Thanks,
Avinash

Jan Gunnar Helg
Honored Contributor.

Re: How to remove CI relations using sd_event?

Ok but I need to do this without doing direct updates in the database.
Sam decosta
Outstanding Contributor.

Re: How to remove CI relations using sd_event?

I DB/UI Rules we don't have option to perform this task, so we can do it only in databse level.

Thanks,
Avinash
Jan Gunnar Helg
Honored Contributor.

Re: How to remove CI relations using sd_event?

It should be possible using SD_EVENT with delete parameter, I just cant figure out the syntax.

Using a combination of DB rules and a direct SQL update is both resource intesnive/slow and unsafe so I won't do that :(
Sam decosta
Outstanding Contributor.

Re: How to remove CI relations using sd_event?

Let me also know If you got solution by using sd_event then probably i can also stop DB rule in my HPSD.

madriss
Regular Contributor.

Re: How to remove CI relations using sd_event?

why not use a web api to develop java script to remove the relationship between CI. With sd_event and even sd_import, only you can change the relationship between a CI relationship with a name Removed
Jan Gunnar Helg
Honored Contributor.

Re: How to remove CI relations using sd_event?

Colleague came up with the solution :)

public string DeleteCIRelation(string CIFrom, string CITo, string Relation, string username, string password)
{

StringBuilder messagebody = new StringBuilder();
messagebody.Append("username=" + username);
messagebody.Append("\npassword=" + password);
messagebody.Append("\nmapping=CMDB_EVENT_CI_RELATION\nclassName=CMDB_EVENT_CI_RELATION\nmodus=DELETE");
messagebody.Append("\nCIFROM=" + CIFrom );
messagebody.Append("\nCITO=" + CITo );
messagebody.Append("\nRELATION=" + Relation);

strDebugMe