<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Accessing Custom Attributes from node's parent containers]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I have a relatively large NetXMS deployment and I have nodes organized in multi-level container hierarchy, e.g.:</p>
<p dir="auto">-Infrastructure<br />
|__Client1<br />
     |___PDC<br />
             |___Node1<br />
             |___Node2<br />
             |___Node3<br />
     |___DRC<br />
             |___Node1<br />
             |___Node2<br />
             |___Node3<br />
     |___Branches<br />
             |___East-Side<br />
                      |____Node1<br />
                      |____Node2<br />
                      |____Node3<br />
             |___West-Side<br />
                      |____Node1<br />
                      |____Node2<br />
                      |____Node3<br />
|__Client2<br />
     |___PDC<br />
             |___Node1<br />
             |___Node2<br />
             |___Node3<br />
     |___DRC<br />
             |___Node1<br />
             |___Node2<br />
             |___Node3<br />
     |___Branches<br />
             |___East-Side<br />
                      |____Node1<br />
                      |____Node2<br />
                      |____Node3<br />
             |___West-Side<br />
                      |____Node1<br />
                      |____Node2<br />
                      |____Node3<br />
.... and so on..</p>
<p dir="auto">What i want to achieve is to set few custom attributes on higher-level containers (e.g. Client1, Client2) with general client-specific info such as contact details, email notification recipients, etc. that i can use in events and actions.<br />
In order to achieve that i need some sort of Custom Attribute "inheritance" from top to bottom, or alternatively a way to access parent containers custom attributes.</p>
<p dir="auto">Is there a way to achieve that?</p>
]]></description><link>https://forum.netxms.org/topic/4077/accessing-custom-attributes-from-node-s-parent-containers</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 16:04:56 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/4077.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 05 Nov 2015 11:25:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Accessing Custom Attributes from node's parent containers on Fri, 06 Nov 2015 11:45:31 GMT]]></title><description><![CDATA[<p dir="auto">Thanks Victor,<br />
I'll give it a try and post feedback.</p>
]]></description><link>https://forum.netxms.org/post/18201</link><guid isPermaLink="true">https://forum.netxms.org/post/18201</guid><dc:creator><![CDATA[blazarov]]></dc:creator><pubDate>Fri, 06 Nov 2015 11:45:31 GMT</pubDate></item><item><title><![CDATA[Reply to Accessing Custom Attributes from node's parent containers on Fri, 06 Nov 2015 09:41:26 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">below is an example of the script that walks all parents of a node and collects values of custom attribute "contacts" into single string separated by semicolons:</p>
<pre><code>global contacts = "";

foreach(o : GetObjectParents($node))
{
	add_contacts(o);
}

println "Contacts: " . contacts;

sub add_contacts(curr)
{
	c = GetCustomAttribute(curr, "contacts");
	if (c != null)
	{
	   if (length(contacts) &gt; 0)
			contacts = contacts . ";" . c;
		else
			contacts = c;
	}

	foreach(o : GetObjectParents(curr))
	{
		add_contacts(o);
	}
}
</code></pre>
<p dir="auto">The only drawback is that it will not detect duplicate values. Duplicates can be eliminated like this:</p>
<pre><code>global contacts = "";
global presense = %{ };

foreach(o : GetObjectParents($node))
{
	add_contacts(o);
}

println "Contacts: " . contacts;

sub add_contacts(curr)
{
	c = GetCustomAttribute(curr, "contacts");
	if ((c != null) &amp;&amp; (presense[c] == null))
	{
	   if (length(contacts) &gt; 0)
			contacts = contacts . ";" . c;
		else
			contacts = c;
		presense[c] = true;
	}

	foreach(o : GetObjectParents(curr))
	{
		add_contacts(o);
	}
}
</code></pre>
<p dir="auto">Note that this script version requires server 2.0-RC1 or higher as it uses hash maps.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/18188</link><guid isPermaLink="true">https://forum.netxms.org/post/18188</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Fri, 06 Nov 2015 09:41:26 GMT</pubDate></item><item><title><![CDATA[Reply to Accessing Custom Attributes from node's parent containers on Thu, 05 Nov 2015 11:34:44 GMT]]></title><description><![CDATA[<p dir="auto">You can do this with a script that will recursively look at objects parents, until it finds a correct custom attribute which you are interested in.</p>
<p dir="auto">Its a bit painful, and not usable everywhere, but it might help you atleast a little.</p>
]]></description><link>https://forum.netxms.org/post/18175</link><guid isPermaLink="true">https://forum.netxms.org/post/18175</guid><dc:creator><![CDATA[tomaskir]]></dc:creator><pubDate>Thu, 05 Nov 2015 11:34:44 GMT</pubDate></item></channel></rss>