Hello,
we are trying to apply templates based on OS type (linux/windows)
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?
if (!$object || !$object.isNode())
   return false;
pn = LowerCase($object.platformName);
if ((pn != null) && StrStartsWith(pn, "windows"))
   return true;
sd = LowerCase($object.snmpSysDescription);
return (sd != null) && (StrFind(sd, "windows") != -1);
			
			
			
				Here's a fixed version: 
if (!$node)
   return false;
pn = $object.platformName.toLowerCase();
if (pn != null && pn.startsWith("windows"))
   return true;
sd = $object.sysDescription.toLowerCase();
return (sd != null && sd.contains("windows"));
$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?
			
			
			
				Yes,Ai was used to create snippet.
Also How can we test it/force it to show results? Or is the only option to wait?
			
			
			
				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. 
In addition, when you execute it that way you can use println() commands to print, so you can use it for debugging purposes. 
			
			
			
				We were able tu use shorter code snippet
return $node->isAgent && $node->platformName like "windows-*";
It returns the same output.
Thx for the help
			
			
			
				It's better to add check for $node:
return $node && $node->isAgent && $node->platformName like "windows-*";
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. 
			
			
			
				Ok, changed the code, thx again for the info ;)