Hints on NXSL for acquiring list of ReponsibleUsers' email address
-
Hello,
On yesterday Q&A Webex session i've got a great idea on how to solve a challenge that i have for years - have generic EPP & Email notification actions, while selecting email recipients based on user's email addresses and group membership.
Apparently this can be implemented elegantly using the new feature Responsible Users.
Users and group objects can be set as Responsible Users on nodes and containers.
Then NXSL have the necessary functionality to write a script that finds the responsible users for a given node and return a list of their email addresses.
Then this script can be run through a macro in email notification action recipient address field - hopefully with a $node parameter. So that this script always returns the full list of email recepients for this particular node.All above combined together will deliver exactly what i need - if i understand it correctly.
I spent few hours trying to develop such a NXSL script, but failed miserably. Can someone help with some hints? I am sure this will be beneficial for the community, not just me.
Thanks!
-
Hi!
Here's an example of such script:
global emails = ""; sub parseGroupsOrUsers(arr) { for (i : arr) { if (i->isGroup) { parseGroupsOrUsers(i->members); } else { if (i->email != "") { if (emails != "") emails = emails . "; "; emails = emails . i->email; } } } } parseGroupsOrUsers($node -> responsibleUsers); println(emails);In NetXMS users groups can contain not only users, but also user groups, hence the script is recursive.
Here's a not-yet-documented way to print all attributes and values of responsible users/gropus:
for (r : $node->responsibleUsers) { for(a : r->__class->attributes) println(a . " = " . r->__get(a)); println; }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login