AutoAdd node if last value is X

Started by Borgso, December 11, 2013, 02:38:11 PM

Previous topic - Next topic

Borgso

Is it possible to autoadd a node if i have a Generic template gathering a value i want to decide where the node should be put?

Ex i have template that check for program version "Templates->Generic->AppVersion"

If AppVersion >=1.0 add to node to "Templates->Generiv_v1"
If AppVersion >=2.0 add to node to "Templates->Generiv_v2"

KjellO

It is possible to check DCI values in template autoapply scripts.

In the generic template, create a DCI that collects the application version.
In the autoapply script of the version-specific template use something like this. (Not tested, may contain errors)

sub main() {
   ver = GetDCIValue($node, FindDCIByName($node, "AppVersion(theApp)"));
   // nxsl finally uses short-circuit evaluation :-)
   return (ver != NULL && $node->name ~= "node-name-regexp" && real(ver) > 1.2 && real(ver) < 2.0);
}



Borgso

Thanks for the help.

I ended up with this AutomaticApplyRules that worked:

sub main() {
   $ver = GetDCIValue($node, FindDCIByDescription($node, "AppVersionDescription"));
   return ($ver != NULL &&
           $node->name ~= "node-name-regexp" &&
           real($ver) > 2);
}