Difference between revisions of "Script Example: Recursively Collect Values from Custom Attributes"
Jump to navigation
Jump to search
(Created page with "This script recursively collects values of custom attribute '''contacts''' from all node parents. Collected values concatenated into single string and separated by semicolons....") |
(No difference)
|
Revision as of 09:48, 6 November 2015
This script recursively collects values of custom attribute contacts from all node parents. Collected values concatenated into single string and separated by semicolons. Duplicate values added only once.
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) && (presense[c] == null))
{
if (length(contacts) > 0)
contacts = contacts . ";" . c;
else
contacts = c;
presense[c] = true;
}
foreach(o : GetObjectParents(curr))
{
add_contacts(o);
}
}