<?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[Automatic Apply rules based on OS type]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">we are trying to apply templates based on OS type (linux/windows)</p>
<p dir="auto">We have created and applied following filtering script on Automatic Apply Rules tab on Template Object properties, but no targets have been added. Is there anything we are doing wrong?</p>
<pre><code>if (!$object || !$object.isNode())
   return false;

pn = LowerCase($object.platformName);
if ((pn != null) &amp;&amp; StrStartsWith(pn, "windows"))
   return true;

sd = LowerCase($object.snmpSysDescription);
return (sd != null) &amp;&amp; (StrFind(sd, "windows") != -1);
</code></pre>
]]></description><link>https://forum.netxms.org/topic/8254/automatic-apply-rules-based-on-os-type</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 10:20:46 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/8254.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 11 Sep 2025 11:19:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Automatic Apply rules based on OS type on Fri, 12 Sep 2025 07:36:18 GMT]]></title><description><![CDATA[<p dir="auto">Ok, changed the code, thx again for the info <img src="https://forum.netxms.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=72b86a538fc" class="not-responsive emoji emoji-android emoji--wink" style="height:1.4em;width:auto;vertical-align:middle" title=";)" alt="😉" /></p>
]]></description><link>https://forum.netxms.org/post/34819</link><guid isPermaLink="true">https://forum.netxms.org/post/34819</guid><dc:creator><![CDATA[maliodpalube]]></dc:creator><pubDate>Fri, 12 Sep 2025 07:36:18 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic Apply rules based on OS type on Thu, 11 Sep 2025 14:17:19 GMT]]></title><description><![CDATA[<p dir="auto">It's better to add check for $node:</p>
<p dir="auto">return $node &amp;&amp; $node-&gt;isAgent &amp;&amp; $node-&gt;platformName like "windows-*";</p>
<p dir="auto">the reason is that there are some other types of object - clusters, sensors, collectors on which templates can also be applied, but there will be no $node on these objects.</p>
]]></description><link>https://forum.netxms.org/post/34817</link><guid isPermaLink="true">https://forum.netxms.org/post/34817</guid><dc:creator><![CDATA[Filipp Sudanov]]></dc:creator><pubDate>Thu, 11 Sep 2025 14:17:19 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic Apply rules based on OS type on Thu, 11 Sep 2025 13:12:52 GMT]]></title><description><![CDATA[<p dir="auto">We were able tu use shorter code snippet</p>
<pre><code>return $node-&gt;isAgent &amp;&amp; $node-&gt;platformName like "windows-*";
</code></pre>
<p dir="auto">It returns the same output.</p>
<p dir="auto">Thx for the help</p>
]]></description><link>https://forum.netxms.org/post/34814</link><guid isPermaLink="true">https://forum.netxms.org/post/34814</guid><dc:creator><![CDATA[maliodpalube]]></dc:creator><pubDate>Thu, 11 Sep 2025 13:12:52 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic Apply rules based on OS type on Thu, 11 Sep 2025 12:15:18 GMT]]></title><description><![CDATA[<p dir="auto">You can easily test it - just take any node, select Execute script from the context menu and paste your script there. Your script will be executed in the same way as when a template executes it on nodes.</p>
<p dir="auto">In addition, when you execute it that way you can use println() commands to print, so you can use it for debugging purposes.</p>
]]></description><link>https://forum.netxms.org/post/34812</link><guid isPermaLink="true">https://forum.netxms.org/post/34812</guid><dc:creator><![CDATA[Filipp Sudanov]]></dc:creator><pubDate>Thu, 11 Sep 2025 12:15:18 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic Apply rules based on OS type on Thu, 11 Sep 2025 12:11:19 GMT]]></title><description><![CDATA[<p dir="auto">Yes,Ai was used to create snippet.</p>
<p dir="auto">Also How can we test it/force it to show results? Or is the only option to wait?</p>
]]></description><link>https://forum.netxms.org/post/34811</link><guid isPermaLink="true">https://forum.netxms.org/post/34811</guid><dc:creator><![CDATA[maliodpalube]]></dc:creator><pubDate>Thu, 11 Sep 2025 12:11:19 GMT</pubDate></item><item><title><![CDATA[Reply to Automatic Apply rules based on OS type on Thu, 11 Sep 2025 12:07:15 GMT]]></title><description><![CDATA[<p dir="auto">Here's a fixed version:</p>
<pre><code>if (!$node)
   return false;

pn = $object.platformName.toLowerCase();
if (pn != null &amp;&amp; pn.startsWith("windows"))
   return true;

sd = $object.sysDescription.toLowerCase();
return (sd != null &amp;&amp; sd.contains("windows"));
</code></pre>
<p dir="auto">$object always exists, so there's no need to check for that. NXSL never had LowerCase() or StrStartsWith() functions, did you use an AI to generate this?</p>
]]></description><link>https://forum.netxms.org/post/34810</link><guid isPermaLink="true">https://forum.netxms.org/post/34810</guid><dc:creator><![CDATA[Filipp Sudanov]]></dc:creator><pubDate>Thu, 11 Sep 2025 12:07:15 GMT</pubDate></item></channel></rss>