Difference between revisions of "NXSL:GetCustomAttribute"

From NetXMS Wiki
Jump to navigation Jump to search
m (Text replacement - "^" to "{{deprecated}}")
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
{{deprecated}}__NOTOC__
Get value of node's custom attribute. Function returns requested attribute's value on success or NULL if given attribute does not exist.
Get value of objects custom attribute.


== Syntax ==
== Syntax ==
GetCustomAttribute(''node'', ''attributeName'')
GetCustomAttribute(''object'', ''attributeName'')


== Parameters ==
== Parameters ==
{| class="wikitable"
{| class="wikitable"
|-
|-
| ''node'' || [[NXSL:Node|Node]] object, you can use predefined variable $node to refer to current node. You can also use null as node if trusted nodes check is disabled (see [[SG:Security Issues|Security Issues]] for more information).
| ''object'' || Any object of [[NXSL_Class_Reference|NetObj class]], or its sub-classes.
You can use predefined variable $node to refer to current node. You can also use null as node if trusted nodes check is disabled (see [[SG:Security Issues|Security Issues]] for more information).
|-
|-
| ''attributeName'' || Custom attribute name.
| ''attributeName'' || Custom attribute name.
Line 15: Line 16:
== Return Value ==
== Return Value ==


String value of custom attribute or '''NULL''' if attribute is missing.
String value of requested custom attribute or '''NULL''' if attribute is missing.


== Notes ==
== Notes ==
If attribute name conforms to NXSL identifier naming conventions, it can be accessed directly as node object attribute. For example “GetCustomAttribute($node, "my_attribute")” can be changed to “$node->my_attribute”
If attribute name conforms to NXSL identifier naming conventions, it can be accessed directly as node object attribute. For example “GetCustomAttribute($node, "my_attribute")” can be changed to “$node->my_attribute”. If custom attribute does not exist, accessing via "->" will generate error. Alternative way it to use syntax "my_attribute@$node", which will return NULL for missing attribute instead.


== Examples ==
== Examples ==


  GetCustomAttribute($node, "my_attribute") -> "my value"
  GetCustomAttribute($node, "my_attribute") -> "my value"
  GetCustomAttribute($node, "bad_attribute_name") -> NULL
  GetCustomAttribute($node, "bad_attribute_name") -> NULL

Latest revision as of 18:13, 13 September 2022

This Wiki is deprecated and we are are currrently migrating remaining pages into product documentation (Admin Guide, NXSL Guide)

Get value of objects custom attribute.

Syntax

GetCustomAttribute(object, attributeName)

Parameters

object Any object of NetObj class, or its sub-classes.

You can use predefined variable $node to refer to current node. You can also use null as node if trusted nodes check is disabled (see Security Issues for more information).

attributeName Custom attribute name.

Return Value

String value of requested custom attribute or NULL if attribute is missing.

Notes

If attribute name conforms to NXSL identifier naming conventions, it can be accessed directly as node object attribute. For example “GetCustomAttribute($node, "my_attribute")” can be changed to “$node->my_attribute”. If custom attribute does not exist, accessing via "->" will generate error. Alternative way it to use syntax "my_attribute@$node", which will return NULL for missing attribute instead.

Examples

GetCustomAttribute($node, "my_attribute")	-> "my value"
GetCustomAttribute($node, "bad_attribute_name")	-> NULL