I would like to check if a list of elements are part of services before I would remove them from the system.
I tried checking if there are any flags on the element that would indicate it's part of a service, but I don't see any.
Is there an easy way to check if an element is part of a service in an automation script?
Hi Jeroen,
Not a direct answer to your question. There is an ad-hoc data source that provides this information: SLC-GQIDS-GetAllElementsInService. From here you could:
- Reuse the code available in the ad-hoc data source in your automation script.
- Use the ad-hoc data source in a dashboard/LCA to retrieve this information.
Hope it helps.


below is the code that works best for my use-case.
public static string[] hcoConnectors = new string[]
{
"Evertz 7800R2x2-ACS-3G",
"Snell Wilcox HCO51 RollCall",
"Snell Wilcox IQHCO3193-1A"
};
private void RunSafe(IEngine engine)
{
IDms thisDms = engine.GetDms();
//This gets all the services in the DMS
ICollection<IDmsService> allServices = thisDms.GetServices();
List<IDmsElement> allStandaloneElementsForHCOs = new List<IDmsElement>();
// Collect all HCO elements
foreach (string connector in hcoConnectors)
{
Element[] elementsForConnector = engine.FindElementsByProtocol(connector);
foreach (Element element in elementsForConnector)
{
IDmsElement myElement = thisDms.GetElement(element.ElementName);
if (myElement != null)
{
allStandaloneElementsForHCOs.Add(myElement);
}
}
}
// Collect all element IDs associated with services
HashSet<(int DataMinerId, int ElementId)> serviceElementIds = new HashSet<(int, int)>();
foreach (IDmsService service in allServices)
{
ServiceParamSettings[] parameters = service.ParameterSettings.IncludedParameters;
foreach (ServiceParamSettings parameter in parameters)
{
int dataMinerId = parameter.DataMinerID;
int elementId = parameter.ElementID;
serviceElementIds.Add((dataMinerId, elementId));
}
}
// Build email content for unused HCO elements
StringBuilder emailBody = new StringBuilder();
emailBody.AppendLine("Overview of Unused HCO Elements:");
emailBody.AppendLine("——————————–");
bool hasUnusedElements = false;
foreach (IDmsElement hcoElement in allStandaloneElementsForHCOs)
{
if (!serviceElementIds.Contains((hcoElement.AgentId, hcoElement.Id)))
{
hasUnusedElements = true;
emailBody.AppendLine($"Element: {hcoElement.Name} (DataMinerId: {hcoElement.AgentId}, ElementId: {hcoElement.Id})");
}
}
// Send email if there are unused elements
if (hasUnusedElements)
{
string subject = "Unused HCO Elements Report – " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
string body = emailBody.ToString();
string to = "jeroen.geldhof@skyline.be";
engine.SendEmail(body, subject, to);
engine.GenerateInformation("Email sent with overview of unused HCO elements.");
}
else
{
engine.GenerateInformation("No unused HCO elements found.");
}
}
Hi Miguel. Unfortunately it seems to do the opposite and returns the elements in a given service.
I'm looking for a way to check which services a given element is part of.
At the moment I think the only way is to go over all services to build a map of the elements they contain and then to cross-check that against the list of elements I'd like to check.