• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Are event messages available in scripts?

    How-To
    2
    6
    1.5k
    Loading More Posts
    • 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.
    • W
      Wingnut2.0
      last edited by

      Hello,

      I would like to forward on events as they are received using the HttpBuilder similar to this topic https://forum.infiniteautomation.com/topic/3169/send-alarm-notification-to-mobile-phone

      The difference is that I would like to send on all events as they are received. Is there a way to make an incoming event message available to a scripting source (possibly the text sent in an Event email)?

      If possible, what would be the scripts context reference used to trigger the script?

      Thank you.

      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by

        Hi Wingnut2.0,

        There is no event handler for "all" events, although that feature was implemented on a branch and not yet picked up.

        For now, I would advise polling with a script for events, using a script on a cron. It's not as responsive as being event driven (although you could poll with the script arbitrarily quickly), doing something like what occurs in this thread, but probably for a time period less than a day and more like a minute: https://forum.infiniteautomation.com/topic/3147/email-last-day-s-events

        In that script the eventList is a com.serotonin.m2m2.rt.event.EventInstance and have a method .getMessageString() that will return the translated message. https://github.com/infiniteautomation/ma-core-public/blob/main/Core/src/com/serotonin/m2m2/rt/event/EventInstance.java

        1 Reply Last reply Reply Quote 0
        • W
          Wingnut2.0
          last edited by

          Thank you Phillip, this was very helpful.
          I was not able to get this running on 3.6.0-beta.6 (not a huge deal), but no problems with 3.5.6.

          1 Reply Last reply Reply Quote 0
          • phildunlapP
            phildunlap
            last edited by phildunlap

            Certainly!

            Do you mean that you tried it on the beta and it didn't work or you're saying that you're not using the beta and it still works? It should work for lots of older versions and still in future versions, as the post about the events email is a year and a half old at least.

            1 Reply Last reply Reply Quote 0
            • W
              Wingnut2.0
              last edited by

              I tried it on 3.6.0-beta.6 and received the following error -
              java.lang.RuntimeException: java.lang.ClassNotFoundException: com.serotonin.m2m2.Common.getTranslations

              I had an instance of 3.5.6 open and tried it there as well. It worked without error.

              1 Reply Last reply Reply Quote 0
              • phildunlapP
                phildunlap
                last edited by

                In 3.6 security was added to scripts to ensure that only a script with superadmin permissions could invoke Java code. That's probably what you're seeing.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post