Skip to main content

addMetadata(key, value, addToUserProperties?)

Adds metadata to CommandBar.

Example

window.CommandBar.addMetadata("userIsWorkspaceOwner", true);

Method parameters

key Required

string

The key for the metadata. Used to reference it in other places, e.g., Command Rules.

value Required

any

There are two options:

  • Value: A literal value (e.g. true)
  • Dynamic: A function to load a value for key, used to lazily load a metadata value. Dynamic values are refreshed on page load and on Bar open.

In general, you should always use static loading where possible. Note that with dynamic loading, metadata won't always be available to control shortcut availability, since loader functions aren't called when a shortcut is run. When using shortcuts, we highly recommend using only static values.

addToUserProperties

boolean

Whether or not to add the metadata to the user properties object (see boot). Defaults to false.