Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. Hints on NXSL for acquiring list of ReponsibleUsers' email address

Hints on NXSL for acquiring list of ReponsibleUsers' email address

Scheduled Pinned Locked Moved Support
2 Posts 2 Posters 9.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B
    B
    blazarov
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • F
      F
      Filipp Sudanov
      wrote on last edited by
      #2

      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;
      }
      
      1 Reply Last reply
      0

      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
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      Powered by NodeBB Contributors
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups