<?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[How to get event instance data as object using Script Event Handler]]></title><description><![CDATA[<p dir="auto">Hello everyone,</p>
<p dir="auto">We started exploring new scripting environment and currently trying to use Script Event Handlers instead of Set Point Event Handlers (Set To Scripted Value). We are be able to use the <strong>evt variable</strong> in global scripts with the code in below</p>
<pre><code>function myHandler(evt) {
    var point = evt.context.point;
    var pointXid = evt.context.point.xid;
    var pointTags = point.tags;
</code></pre>
<p dir="auto">But in the new Script Event Handler the <strong>evt variable</strong> returns a string. Is there a way to format evt variable into a proper object or do we need to do this in a different way in the new scripting environment?</p>
<p dir="auto">Thanks,<br />
Mert</p>
]]></description><link>https://forum.mango-os.com/topic/5268/how-to-get-event-instance-data-as-object-using-script-event-handler</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 23:38:51 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/5268.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 Aug 2021 07:39:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to get event instance data as object using Script Event Handler on Wed, 04 Aug 2021 13:38:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mert" aria-label="Profile: mert">@<bdi>mert</bdi></a> sorry for the delay.  Another option would be to use the Service that is injected into the context like this:</p>
<pre><code>const dataSourceService = services.dataSourceService;
const ip = dataSourceService.get('xid');
</code></pre>
<p dir="auto">Also here is a collection of example scripts for the new environment and a few for the legacy one:</p>
<p dir="auto"><a href="https://github.com/infiniteautomation/script-examples" rel="nofollow ugc">https://github.com/infiniteautomation/script-examples</a></p>
]]></description><link>https://forum.mango-os.com/post/26917</link><guid isPermaLink="true">https://forum.mango-os.com/post/26917</guid><dc:creator><![CDATA[terrypacker]]></dc:creator><pubDate>Wed, 04 Aug 2021 13:38:11 GMT</pubDate></item><item><title><![CDATA[Reply to How to get event instance data as object using Script Event Handler on Wed, 04 Aug 2021 13:19:54 GMT]]></title><description><![CDATA[<p dir="auto">I figured out how to do it by using java class methods in <a href="https://github.com/infiniteautomation/ma-core-public" rel="nofollow ugc">ma-core-public</a>.</p>
<pre><code>const DataSourceDao = Java.type('com.serotonin.m2m2.db.dao.DataSourceDao');

function myHandler(evt) {
    var point = evt.getContext().context.get("point");
    var pointXid = point.getXid();
    var pointTags = point.getTags();

    var dataSourceXid = point.getDataSourceXid();
    var ip = DataSourceDao.getInstance().getByXid(dataSourceXid).getHost();</code></pre>
]]></description><link>https://forum.mango-os.com/post/26916</link><guid isPermaLink="true">https://forum.mango-os.com/post/26916</guid><dc:creator><![CDATA[Mert]]></dc:creator><pubDate>Wed, 04 Aug 2021 13:19:54 GMT</pubDate></item></channel></rss>