metadata
- Description:
Item metadata namespace. This namespace provides access to Item metadata.
- Source:
Classes
Methods
(static) addMetadata(itemOrName, namespace, value, configurationopt, persistopt) → {ItemMetadata}
- Description:
Adds metadata of a single namespace to an Item.
If this is called from file-based scripts, the metadata is registered with the ScriptedMetadataProvider and shares the same lifecycle as the script. You can still persist the metadata permanently in this case by setting the
persist
parameter totrue
. If this is called from UI-based scripts, the metadata is stored to the ManagedMetadataProvider and independent of the script's lifecycle.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
itemOrName |
Item | string |
|
||
namespace |
string | name of the metadata |
||
value |
string | value for this metadata |
||
configuration |
object |
<optional> |
optional metadata configuration |
|
persist |
boolean |
<optional> |
false
|
whether to persist the metadata permanently (only respected for file-based scripts) |
Throws:
-
if the Item already has metadata of the given namespace
- Type
- Error
Returns:
the added metadata
- Type
- ItemMetadata
(static) getMetadata(itemOrName, namespaceopt) → {Object|ItemMetadata|null}
- Description:
Gets metadata of a single namespace or of all namespaces from a given Item.
- Source:
- See:
-
- items.Item.getMetadata
Example
// Get metadata of ALL namespaces
var meta = items.metadata.getMetadata(items.Hallway_Light);
var namespaces = Object.keys(meta); // Get metadata namespaces
// Get metadata of a single namespace
meta = items.metadata.getMetadata(items.Hallway_Light, 'expire');
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
itemOrName |
Item | string |
|
|
namespace |
string |
<optional> |
name of the metadata: if provided, only metadata of this namespace is returned, else all metadata is returned |
Returns:
all metadata as an object with the namespaces as properties OR metadata of a single namespace or null
if that namespace doesn't exist; the metadata itself is of type ItemMetadata
- Type
- Object | ItemMetadata | null
(static) removeMetadata(itemOrName, namespaceopt) → {ItemMetadata|null}
- Description:
Removes metadata of a single namespace or of all namespaces from a given Item.
- Source:
- See:
-
- items.Item.removeMetadata
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
itemOrName |
Item | string |
|
|
namespace |
string |
<optional> |
name of the metadata: if provided, only metadata of this namespace is removed, else all metadata is removed |
Returns:
removed metadata OR null
if the Item has no metadata under the given namespace, or it cannot be removed or all metadata was removed
- Type
- ItemMetadata | null
(static) replaceMetadata(itemOrName, namespace, value, configurationopt) → {ItemMetadata|null}
- Description:
Updates or adds metadata of a single namespace to an Item. When using file-based scripts, it is recommended to use
items.metadata.addMetadata
instead.If metadata is not provided by this script or the ManagedMetadataProvider, it is not editable and a warning is logged.
- Source:
- See:
-
- items.Item.replaceMetadata
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
itemOrName |
Item | string |
|
|
namespace |
string | name of the metadata |
|
value |
string | value for this metadata |
|
configuration |
object |
<optional> |
optional metadata configuration |
Returns:
old metadata or null
if the Item had no metadata with the given name
- Type
- ItemMetadata | null