<?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[Function FindObject returns wrog object class when node as argument]]></title><description><![CDATA[<p dir="auto">According to source codes, the function should return generic object class or null<br />
/**<br />
 * Find object<br />
 * First argument: object id or name<br />
 * Second argument (optional): current node object or null<br />
 * Returns generic object or null if requested object was not found or access to it was denied<br />
 */</p>
<p dir="auto">If I call the function with a node as argument<br />
o=FindObject(nodeid);<br />
the <br />
o-&gt;type<br />
returns: ERROR: Script finished with error: Error 15 in line XX: Unknown object's attribute</p>
<p dir="auto">With container ID as parameter is not problem.</p>
<p dir="auto">So I think the function is returning Node pointer when the argument is the node.</p>
<p dir="auto">From my point of sight is it wrong behaviour. For this purpose exist FindNodeObject.</p>
<p dir="auto">Martin</p>
<p dir="auto"> </p>
<p dir="auto">Code example<br />
sub main() {</p>
<p dir="auto">n=FindObject(10506);   // node class type</p>
<p dir="auto">  println("Name: " . n-&gt;name . " ID: " . n-&gt;id);<br />
  println("snmpSysName: " . n-&gt;snmpSysName); // WRONG - returns a snmpSysname value<br />
  println("Type: " . n-&gt;type);  //WRONG - shoul return "2", but returns<br />
             // - ERROR: Script finished with error: Error 15 in line XX: Unknown object's attribute<br />
 <br />
n=FindObject(219);   //Container class type</p>
<p dir="auto">  println("Name: " . n-&gt;name . " ID: " . n-&gt;id);<br />
  println("snmpSysName: " . n-&gt;snmpSysName); //CORRECT error message, snmpSysName does not exists in netobj"<br />
                  // - ERROR: Script finished with error: Error 15 in line XX: Unknown object's attribute<br />
  println("Type: " . n-&gt;type);  //CORRECT - returns "5"</p>
<p dir="auto">}</p>
]]></description><link>https://forum.netxms.org/topic/4248/function-findobject-returns-wrog-object-class-when-node-as-argument</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 09:18:40 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/4248.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Jan 2016 13:06:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Function FindObject returns wrog object class when node as argument on Wed, 27 Jan 2016 10:21:19 GMT]]></title><description><![CDATA[<p dir="auto">Thank you, will wait for new release.</p>
<p dir="auto">Martin</p>
]]></description><link>https://forum.netxms.org/post/19023</link><guid isPermaLink="true">https://forum.netxms.org/post/19023</guid><dc:creator><![CDATA[maredcz]]></dc:creator><pubDate>Wed, 27 Jan 2016 10:21:19 GMT</pubDate></item><item><title><![CDATA[Reply to Function FindObject returns wrog object class when node as argument on Wed, 27 Jan 2016 09:03:47 GMT]]></title><description><![CDATA[<p dir="auto">It should be fixed in 2.0.2 (as Alex mentioned) which will be released very soon. <img src="https://forum.netxms.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=72b86a538fc" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /><br />
Please check after release if it works correctly for you as well.</p>
<p dir="auto">For me (running on 2.0.2 development build), the output of the script is correct:</p>
<pre><code>FindObject - Class of node object: 4535 is Node
Type of node object: 2

*** FINISHED ***
</code></pre>
]]></description><link>https://forum.netxms.org/post/19020</link><guid isPermaLink="true">https://forum.netxms.org/post/19020</guid><dc:creator><![CDATA[tomaskir]]></dc:creator><pubDate>Wed, 27 Jan 2016 09:03:47 GMT</pubDate></item><item><title><![CDATA[Reply to Function FindObject returns wrog object class when node as argument on Wed, 27 Jan 2016 08:55:35 GMT]]></title><description><![CDATA[<p dir="auto">Hello Tomas, to be exactly I have a problem with NetObj's "TYPE attribute" when the object is Node.<br />
As mentioned in Documentation, the Node class should inherite all attributes of NetObj class, but the<br />
n-&gt;type returns "ERROR: Script finished with error: Error 15 in line XX: Unknown object's attribute"</p>
<p dir="auto">It happen when the object is node.</p>
<p dir="auto">The Title of this post should be probably<br />
 The type attribute of NetObj cannot be determined when the object is node - Error Unknown object's attribute"</p>
<p dir="auto">node=10506;</p>
<p dir="auto">nodeObject=FindObject(node);</p>
<p dir="auto">// this is a Node<br />
println("FindObject - Class of node object: " . node . " is " . classof(nodeObject));</p>
<p dir="auto">try {<br />
println("Type of node object: " . nodeObject-&gt;type);<br />
} catch {<br />
  println("Query nodeObject-&gt;type. This error should not be displayed, since Node should have the TYPE attribute inherited from NetObj");<br />
}</p>
]]></description><link>https://forum.netxms.org/post/19019</link><guid isPermaLink="true">https://forum.netxms.org/post/19019</guid><dc:creator><![CDATA[maredcz]]></dc:creator><pubDate>Wed, 27 Jan 2016 08:55:35 GMT</pubDate></item><item><title><![CDATA[Reply to Function FindObject returns wrog object class when node as argument on Tue, 26 Jan 2016 13:33:52 GMT]]></title><description><![CDATA[<p dir="auto">Working with 2.0.2 here, the output of this script:</p>
<pre><code>// this is a Container
println(classof(FindObject(125)));

// this is a Node
println(classof(FindObject(4528)));

// this is a Container
try {
  println(classof(FindNodeObject(null, 125)));
} catch {
  println("This error should be displayed, since we are calling classoff(null)");
}

// this is a Node
println(classof(FindNodeObject(null, 4528)));
</code></pre>
<p dir="auto">Is</p>
<pre><code>NetObj
Node
This error should be displayed, since we are calling classoff(null)
Node

*** FINISHED ***
</code></pre>
<p dir="auto">Node is just a sub-class of NetObj, so calling any attributes of the NetObj on a node-class object will of course work.<br />
For reference: <a href="https://wiki.netxms.org/wiki/NXSL_Class_Reference" rel="nofollow ugc">https://wiki.netxms.org/wiki/NXSL_Class_Reference</a>.</p>
<p dir="auto">I have also fixed the FindObject function documentation on the wiki to be more clear on what the current behavior is:<br />
<a href="https://wiki.netxms.org/wiki/NXSL:FindObject" rel="nofollow ugc">https://wiki.netxms.org/wiki/NXSL:FindObject</a></p>
]]></description><link>https://forum.netxms.org/post/19007</link><guid isPermaLink="true">https://forum.netxms.org/post/19007</guid><dc:creator><![CDATA[tomaskir]]></dc:creator><pubDate>Tue, 26 Jan 2016 13:33:52 GMT</pubDate></item><item><title><![CDATA[Reply to Function FindObject returns wrog object class when node as argument on Tue, 26 Jan 2016 10:59:08 GMT]]></title><description><![CDATA[<p dir="auto">The function instanceof is not known im my system.<br />
I am currently running 2.0.1 version.</p>
<p dir="auto">In my case FindObject function returns different classes for Node and Container, but should return only the generic class as mentioned in Documentation.</p>
<p dir="auto">println(classof(FindObject(10506)));  //10506 is Node, FindObject returns "Node"<br />
println(classof(FindObject(219)));   //219 is Container, FindObject returns "NetObj"</p>
<p dir="auto">It is not generally big problem, but it differs from the function description in Documentation pages and source code comments.</p>
<p dir="auto">Martin</p>
]]></description><link>https://forum.netxms.org/post/19004</link><guid isPermaLink="true">https://forum.netxms.org/post/19004</guid><dc:creator><![CDATA[maredcz]]></dc:creator><pubDate>Tue, 26 Jan 2016 10:59:08 GMT</pubDate></item><item><title><![CDATA[Reply to Function FindObject returns wrog object class when node as argument on Mon, 25 Jan 2016 14:13:37 GMT]]></title><description><![CDATA[<p dir="auto">That was actually fixed couple of days ago in <a href="https://git.netxms.org/public/netxms.git/commit/ca5943533c8c9f38d92d17f988a191d498873f09" rel="nofollow ugc">ca594353</a>.</p>
<p dir="auto">But released version still use different classes (Node / NetObj). You can check it this way:<code>if (instanceof(FindObject(123) == "Node") { … }</code></p>
]]></description><link>https://forum.netxms.org/post/18984</link><guid isPermaLink="true">https://forum.netxms.org/post/18984</guid><dc:creator><![CDATA[alk]]></dc:creator><pubDate>Mon, 25 Jan 2016 14:13:37 GMT</pubDate></item><item><title><![CDATA[Reply to Function FindObject returns wrog object class when node as argument on Mon, 25 Jan 2016 13:33:17 GMT]]></title><description><![CDATA[<p dir="auto">Your example code works fine for me.</p>
<p dir="auto">Are you sure you arent dealing with security issues as described here?<br />
<a href="https://wiki.netxms.org/wiki/SG:Security_Issues" rel="nofollow ugc">https://wiki.netxms.org/wiki/SG:Security_Issues</a></p>
<p dir="auto">Here is the code I used:</p>
<pre><code>// node class type
n=FindObject(507);
println("Trying for node...");
println("Name: " . n-&gt;name . " ID: " . n-&gt;id);
// this should not throw error
try {
  println("snmpSysName: " . n-&gt;snmpSysName);
} catch {
  println("Got an error for node!");
}
println("Type: " . n-&gt;type);

println("");

//Container class type
n=FindObject(851);
println("Trying for container...");
println("Name: " . n-&gt;name . " ID: " . n-&gt;id);
// this should throw error
try {
  println("snmpSysName: " . n-&gt;snmpSysName);
} catch {
  println("Got an error for container!");
}
println("Type: " . n-&gt;type);
</code></pre>
]]></description><link>https://forum.netxms.org/post/18978</link><guid isPermaLink="true">https://forum.netxms.org/post/18978</guid><dc:creator><![CDATA[tomaskir]]></dc:creator><pubDate>Mon, 25 Jan 2016 13:33:17 GMT</pubDate></item></channel></rss>