-
Problem report
-
Resolution: Fixed
-
Trivial
-
7.0.10
-
None
-
Documentation backlog
-
1
Steps to reproduce:
We build a template, that has an item and a discovery mechanism that works with the result of the item and create some items to report, if a Windows hotfix is installed or missing.
The first items get some information about the windows os version, that is installed. With this it will return a JSON-array, that we then use in our LLD discovery.
If we test the template it returns everything as intended, but if we link the template to a host, it does not work anymore. The problem is, that it then returns the LLD Macro instead of the content.
Result:
Get the OS version and return the LLD Macro for discovery process.
with that we create an Item, that gets the installed hotfixes
Now we have an depending item, that will check, if the hotfixes (that should be installed) are also installed. This hotfix-numbers should be stored in the LLD macro {#WIN_KBSHOULDBEINSTALLED}. This macro is used in the preprocessing javascript code.
var Hotfixes2Compare = '{#WIN_KBSHOULDBEINSTALLED}'; var installedHotfixes = ''; var TxtOutputPrep = "Missing Hotfixes:"; var TxtOutput = TxtOutputPrep; var isFound = false; return Hotfixes2Compare; comparedHotfixes = JSON.stringify(Hotfixes2Compare); return comparedHotfixes; // if ((Array.isArray(comparedHotfixes))){ return 1} else {return 0}installedHotfixes = JSON.parse(value) // äußere Schleife durchläuft alle KBs, die eingegeben wurden return JSON.stringify(comparedHotfixes), comparedHotfixes.length for (var i = 0; i < comparedHotfixes.length; i++) { isFound = false; // console.log(`comparedHotfixes: ${comparedHotfixes[i]}`); // innere Schleife durchläuft alle installierten Hotfixes // und vergleicht, ob ein eingegebenes Hotfix enthalten ist for (l = 0; l < installedHotfixes.length; l++) { //console.log(`installed Hotfixes: ${JSON.stringify((installedHotfixes[l]).HotfixId)}`); if(comparedHotfixes[i] == installedHotfixes[l].HotfixId ){ //console.log(comparedHotfixes[i],JSON.stringify((installedHotfixes[l]).HotfixId)) isFound = true }; } if(isFound == false){ TxtOutput = TxtOutput + ' ' + comparedHotfixes[i] };}; if(TxtOutput == TxtOutputPrep){TxtOutput = 0}; // console.log(TxtOutput); return TxtOutput; } else { // console.log("Keine Hotfixes gefunden oder ein Fehler ist aufgetreten."); return 9999; }
This code is changed so we could see the output of 'Hotfixes2Compare'. Currently it's value is the String '{#WIN_KBSHOULDBEINSTALLED}'. If we remove the single qoutes, the item doesn't work within the host context. But it will work in the template context, if we pass by the values by hand within the "test all steps" feature.
Expected:
We would expect, that the template does the same in testing template and when it is linked to the host.
We added the template, so you can maybe test it.
Questions:
Is it possible to use LLD macros in preprocessing javascript? What are we doing wrong or is it a bug?
In previous versions of the 7.0 lts, this template works on hosts as intended.