<?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[Scripting general Discussion]]></title><description><![CDATA[Forum for discussions regarding the Mango Scripting environment within Meta Data Points and Scripting Data Sources.]]></description><link>https://forum.mango-os.com/category/14</link><generator>RSS for Node</generator><lastBuildDate>Thu, 18 Jun 2026 13:35:42 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/category/14.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 30 Jul 2024 02:45:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Change a data point with condition]]></title><description><![CDATA[@tungthanh500 get rid of the runtime sleep call. Set the context point related to the data point you are validating and set the script to trigger from one of them for a start.
Alternatively use a cron timer setting set to 15 seconds.
Fox
]]></description><link>https://forum.mango-os.com/topic/5836/change-a-data-point-with-condition</link><guid isPermaLink="true">https://forum.mango-os.com/topic/5836/change-a-data-point-with-condition</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Tue, 30 Jul 2024 02:45:14 GMT</pubDate></item><item><title><![CDATA[Help needed (newbie) Accessing an API with a Scripting Datasource Mango 4.4.2]]></title><description><![CDATA[@MattFox Thanks for posting this Fox!! And thank you again for all your help! Your an invaluable asset to this forum!
Note: For others that try to access this data from the DegreeDays.net API as shown above, you may need to adjust the CRON polling time to something a little later than 12:30AM as listed above. Some weather stations do not fully update yesterdays available Heating Degree Data until a couple hours or so after midnight, so experiment with the CRON polling time accordingly.
]]></description><link>https://forum.mango-os.com/topic/5600/help-needed-newbie-accessing-an-api-with-a-scripting-datasource-mango-4-4-2</link><guid isPermaLink="true">https://forum.mango-os.com/topic/5600/help-needed-newbie-accessing-an-api-with-a-scripting-datasource-mango-4-4-2</guid><dc:creator><![CDATA[raylatbasix]]></dc:creator><pubDate>Tue, 13 Dec 2022 15:33:01 GMT</pubDate></item><item><title><![CDATA[&lt;script&gt; tag not working in Mango V4?]]></title><description><![CDATA[@jared-wiltshire Hi Jared. Is there a better solution for this as i am struggling to create the script as the entry point under User modules? Or perhaps if you can give me quick point as to how to go about this?
]]></description><link>https://forum.mango-os.com/topic/5422/script-tag-not-working-in-mango-v4</link><guid isPermaLink="true">https://forum.mango-os.com/topic/5422/script-tag-not-working-in-mango-v4</guid><dc:creator><![CDATA[Ruan 0]]></dc:creator><pubDate>Wed, 12 Jan 2022 07:50:16 GMT</pubDate></item><item><title><![CDATA[Audible Alarm with silence]]></title><description><![CDATA[@tungthanh500 have you seen the UI settings at  /ui/administration/ui-settings which allow you to choose an audio file? There's no provision to loop an audio file as far as I remember, you would need to create a custom component for this.
]]></description><link>https://forum.mango-os.com/topic/5406/audible-alarm-with-silence</link><guid isPermaLink="true">https://forum.mango-os.com/topic/5406/audible-alarm-with-silence</guid><dc:creator><![CDATA[Jared Wiltshire]]></dc:creator><pubDate>Thu, 16 Dec 2021 13:30:07 GMT</pubDate></item><item><title><![CDATA[Which Point Called Event Handler?]]></title><description><![CDATA[@marganellim the script I gave you is for the "script" section of the email event handler.  That is the only place the "model" is included in the script context as it is normally used to modify the model that is used to generate the Email via the FTL template but you can do anything you want in that script.
The script you use will depend on the type of Event Handler you choose.  If you want to use a "Script" Event Handler then this would work:
/**
 * This script implements com.serotonin.m2m2.rt.event.handlers.EventHandlerInterface
 * Add this script to a "Script" type event handler and choose the Graal.js or Nashorn engine.
 */

/**
 * Called when the Mango event is raised.
 * You must implement this method.
 *
 * @param event
 */
function eventRaised(event) {
    console.log('Raised', event);
    console.log('test xid: ' + event.getContext().get('point').getXid());
}

/**
 * Called when the Mango event is acknowledged (the event may still be active).
 * Supported as of Mango v4.0.0-beta.14, you are not required to implement this method.
 *
 * @param event
 */
function eventAcknowledged(event) {
    console.log('Acknowledged', event);
}

/**
 * Called when the Mango event returns to normal or is deactivated (e.g. on shutdown).
 * You must implement this method.
 *
 * @param event
 */
function eventInactive(event) {
    console.log('Inactive', event);
}



]]></description><link>https://forum.mango-os.com/topic/5335/which-point-called-event-handler</link><guid isPermaLink="true">https://forum.mango-os.com/topic/5335/which-point-called-event-handler</guid><dc:creator><![CDATA[terrypacker]]></dc:creator><pubDate>Sun, 24 Oct 2021 22:33:01 GMT</pubDate></item><item><title><![CDATA[PointValueQuery using where conditions]]></title><link>https://forum.mango-os.com/topic/5334/pointvaluequery-using-where-conditions</link><guid isPermaLink="true">https://forum.mango-os.com/topic/5334/pointvaluequery-using-where-conditions</guid><pubDate>Tue, 19 Oct 2021 00:00:01 GMT</pubDate></item><item><title><![CDATA[IGVault Ways to Make Madden Coins in Madden NFL 21]]></title><link>https://forum.mango-os.com/topic/5184/igvault-ways-to-make-madden-coins-in-madden-nfl-21</link><guid isPermaLink="true">https://forum.mango-os.com/topic/5184/igvault-ways-to-make-madden-coins-in-madden-nfl-21</guid><pubDate>Mon, 17 May 2021 02:25:49 GMT</pubDate></item><item><title><![CDATA[Getting value at specific time using metadata scripting]]></title><description><![CDATA[Have you read https://docs-v3.mango-os.com/about-mango-java-script ?
Look at Statistical objects section. Hint, there is a delta in statistical object.
]]></description><link>https://forum.mango-os.com/topic/5153/getting-value-at-specific-time-using-metadata-scripting</link><guid isPermaLink="true">https://forum.mango-os.com/topic/5153/getting-value-at-specific-time-using-metadata-scripting</guid><dc:creator><![CDATA[ThomasEinasto]]></dc:creator><pubDate>Tue, 06 Apr 2021 11:55:18 GMT</pubDate></item><item><title><![CDATA[Advanced Schedule Present Value in Scripting by XID]]></title><link>https://forum.mango-os.com/topic/5099/advanced-schedule-present-value-in-scripting-by-xid</link><guid isPermaLink="true">https://forum.mango-os.com/topic/5099/advanced-schedule-present-value-in-scripting-by-xid</guid><pubDate>Wed, 17 Feb 2021 15:52:06 GMT</pubDate></item><item><title><![CDATA[Forcasted Data: Purge existing data before writing updated values]]></title><description><![CDATA[Congrats!
]]></description><link>https://forum.mango-os.com/topic/5065/forcasted-data-purge-existing-data-before-writing-updated-values</link><guid isPermaLink="true">https://forum.mango-os.com/topic/5065/forcasted-data-purge-existing-data-before-writing-updated-values</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Sun, 24 Jan 2021 13:19:53 GMT</pubDate></item><item><title><![CDATA[Design pattern to modify an epoch timestamp on modbus tcp]]></title><description><![CDATA[Using a Meta Data Source I think could be possible to format the date as I need but how I can then map to an epoch as required when the user for example change the hour?
]]></description><link>https://forum.mango-os.com/topic/4970/design-pattern-to-modify-an-epoch-timestamp-on-modbus-tcp</link><guid isPermaLink="true">https://forum.mango-os.com/topic/4970/design-pattern-to-modify-an-epoch-timestamp-on-modbus-tcp</guid><dc:creator><![CDATA[etantonio]]></dc:creator><pubDate>Sun, 11 Oct 2020 21:33:09 GMT</pubDate></item><item><title><![CDATA[Its possible load a jsp file from meta data source script?]]></title><link>https://forum.mango-os.com/topic/4851/its-possible-load-a-jsp-file-from-meta-data-source-script</link><guid isPermaLink="true">https://forum.mango-os.com/topic/4851/its-possible-load-a-jsp-file-from-meta-data-source-script</guid><pubDate>Fri, 19 Jun 2020 16:55:05 GMT</pubDate></item><item><title><![CDATA[why can&#x27;t i use setTimeout in scripts ?]]></title><link>https://forum.mango-os.com/topic/4828/why-can-t-i-use-settimeout-in-scripts</link><guid isPermaLink="true">https://forum.mango-os.com/topic/4828/why-can-t-i-use-settimeout-in-scripts</guid><pubDate>Sat, 06 Jun 2020 15:26:09 GMT</pubDate></item><item><title><![CDATA[meta data scripting - execution and setting]]></title><description><![CDATA[No under events, there are different options when an event is triggered. Email, set point value, run external process,excel report, report -&gt; Set to Set point
[image: ZKTo6ba.png]
Then add the same context points you use in your meta data source script, the target point being what you normally send data down via your meta point -&gt; your bacnet point
[image: iHqHCwj.png]
Set to scripted action:
[image: 0LOAKgC.png]
[image: PDRa4UW.png]
Input the same code you would for your meta datapoint script and return the value that the bacnet point should receive.
This will then fire when the event is triggered.
]]></description><link>https://forum.mango-os.com/topic/4788/meta-data-scripting-execution-and-setting</link><guid isPermaLink="true">https://forum.mango-os.com/topic/4788/meta-data-scripting-execution-and-setting</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Fri, 01 May 2020 14:17:25 GMT</pubDate></item><item><title><![CDATA[Point unit view problem in set point event handler]]></title><link>https://forum.mango-os.com/topic/4783/point-unit-view-problem-in-set-point-event-handler</link><guid isPermaLink="true">https://forum.mango-os.com/topic/4783/point-unit-view-problem-in-set-point-event-handler</guid><pubDate>Tue, 28 Apr 2020 08:43:28 GMT</pubDate></item><item><title><![CDATA[MQTT Data Point Scaling]]></title><description><![CDATA[As far as I know, there are not any plans in place right now.  But I do agree that this would be useful for all Numeric data points.
]]></description><link>https://forum.mango-os.com/topic/4775/mqtt-data-point-scaling</link><guid isPermaLink="true">https://forum.mango-os.com/topic/4775/mqtt-data-point-scaling</guid><dc:creator><![CDATA[CraigWeb]]></dc:creator><pubDate>Thu, 16 Apr 2020 06:22:41 GMT</pubDate></item><item><title><![CDATA[How to get email recipient list from another database?]]></title><description><![CDATA[No, because you need to pre-populate the emails to send the alerts to.
What would be better is to run a script on an event going high.
This forum post here shows you how to send an email from the mango javascript system:
https://forum.infiniteautomation.com/topic/3147/email-last-day-s-events/2
If you combine that with the http handler, you can request your recipients, from your other system then populate with the affected recipients emails.
Fox
]]></description><link>https://forum.mango-os.com/topic/4751/how-to-get-email-recipient-list-from-another-database</link><guid isPermaLink="true">https://forum.mango-os.com/topic/4751/how-to-get-email-recipient-list-from-another-database</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Thu, 19 Mar 2020 12:05:16 GMT</pubDate></item><item><title><![CDATA[Global Scripts import only imports the first script]]></title><description><![CDATA[That's about what I expected. Glad it was simple and isolated.
]]></description><link>https://forum.mango-os.com/topic/4747/global-scripts-import-only-imports-the-first-script</link><guid isPermaLink="true">https://forum.mango-os.com/topic/4747/global-scripts-import-only-imports-the-first-script</guid><dc:creator><![CDATA[AldoRamos]]></dc:creator><pubDate>Thu, 12 Mar 2020 22:47:28 GMT</pubDate></item><item><title><![CDATA[Script breaking as of 10&#x2F;16&#x2F;2019]]></title><description><![CDATA[Hey Terry,
This one is also giving a java out of bounds exception, but I don't understand why:
/*
//Script by Phil Dunlap to automatically generate lost history
if( my.time + 60000 &lt; source.time ) { //We're at least a minute after
  var metaEditDwr = new com.serotonin.m2m2.meta.MetaEditDwr();
  metaEditDwr.generateMetaPointHistory(
      my.getDataPointWrapper().getId(), my.time+1, CONTEXT.getRuntime(), false);
  //Arguments are, dataPointId, long from, long to, boolean deleteExistingData
  //my.time+1 because first argument is inclusive, and we have value there
}
//Your regular script here.*/

//Get daily run starts
return runs.past(MINUTE, 1440)['data'].get(true).starts;

]]></description><link>https://forum.mango-os.com/topic/4536/script-breaking-as-of-10-16-2019</link><guid isPermaLink="true">https://forum.mango-os.com/topic/4536/script-breaking-as-of-10-16-2019</guid><dc:creator><![CDATA[mihairosu]]></dc:creator><pubDate>Thu, 24 Oct 2019 14:21:43 GMT</pubDate></item><item><title><![CDATA[HttpBuilder.request()]]></title><description><![CDATA[@phildunlap
Thank you for your prompt reply. It works like a breeze.
In my opinion, this is a powerful tool that open up the doors to communicate with internet of things / web content. In addition it provide flexibility to integrate your creativity into application.
"Logic will get you from A to B. Imagination will take you everywhere".
]]></description><link>https://forum.mango-os.com/topic/4448/httpbuilder-request</link><guid isPermaLink="true">https://forum.mango-os.com/topic/4448/httpbuilder-request</guid><dc:creator><![CDATA[Desmond]]></dc:creator><pubDate>Fri, 06 Sep 2019 03:40:31 GMT</pubDate></item><item><title><![CDATA[Trying to display more than one return meta-point value using javascript]]></title><description><![CDATA[Thanks for pointing that out Craig! We could fix the if condition for this for the default variable name with,
if( this[variableName].value &gt; max &amp;&amp; variableName !== "my" ) {

]]></description><link>https://forum.mango-os.com/topic/4443/trying-to-display-more-than-one-return-meta-point-value-using-javascript</link><guid isPermaLink="true">https://forum.mango-os.com/topic/4443/trying-to-display-more-than-one-return-meta-point-value-using-javascript</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Tue, 03 Sep 2019 17:39:27 GMT</pubDate></item><item><title><![CDATA[Scripting data source points don&#x27;t get a value]]></title><description><![CDATA[Hey Folks,
Thank you so much! It was indeed a newbie thing as suggested by Phil and Fox.
Really appreciate your help.
Jim.
]]></description><link>https://forum.mango-os.com/topic/4436/scripting-data-source-points-don-t-get-a-value</link><guid isPermaLink="true">https://forum.mango-os.com/topic/4436/scripting-data-source-points-don-t-get-a-value</guid><dc:creator><![CDATA[realmooseman]]></dc:creator><pubDate>Thu, 29 Aug 2019 00:03:35 GMT</pubDate></item></channel></rss>