SetCustomerMetadataAttribute

The SetCustomerMetadataAttribute aсtion sets a specific metadata value for a specific attribute. The attribute metadata can be set by providing the attribute's ID, field name, and value.

SetCustomerMetadataAttribute(
    idn: str,
    field: Literal["title", "group", "is_read_only", "is_hidden", "description", "value_type", "possible_values", "multiple_fields"],
    value: Union[str, bool, List[str], dict]
)

Where:

  • idn: The identifier of the attribute. For example, "customer_last_name."
  • field: The specific metadata field you want to set.
ValueDescription
titleSet the title of the attribute.
groupSet the group of the attribute.
is_read_onlySet whether the attribute can be changed.
is_hiddenSet whether the attribute is visible.
descriptionSet a description of the attribute.
value_typeSet the data type of the value ("string", "number", "bool", "json").
possible_valuesSet possible values for the attribute. When set, value_type has no effect because possible_values is a list[str].
multiple_fieldsSet multiple attribute fields at the same time.
  • value: The value to set. Depends on the field you choose.

Examples

{# Set the title of the attribute #}
{{SetCustomerMetadataAttribute(
    idn="customer_last_name",
    field="title",
    value="Last Name"
)}}
{# Set the group of the attribute #}
{{SetCustomerMetadataAttribute(
    idn="customer_last_name",
    field="group",
    value="Personal Info"
)}}
{# Make attribute read-only #}
{{SetCustomerMetadataAttribute(
    idn="customer_last_name",
    field="is_read_only",
    value=True
)}}
{# Hide the attribute #}
{{SetCustomerMetadataAttribute(
    idn="customer_last_name",
    field="is_hidden",
    value=False
)}}
{# Set a description for the attribute #}
{{SetCustomerMetadataAttribute(
    idn="customer_last_name",
    field="description",
    value="The last name (surname) of the customer"
)}}
{# Set the data type of the attribute value #}
{{SetCustomerMetadataAttribute(
    idn="customer_last_name",
    field="value_type",
    value="string"
)}}
{# Set possible values for the attribute #}
{# Note: when possible_values is set, value_type has no effect #}
{{SetCustomerMetadataAttribute(
    idn="customer_status",
    field="possible_values",
    value=["active", "inactive", "pending", "suspended"]
)}}
{# Set multiple attribute fields at once #}
{{SetCustomerMetadataAttribute(
    idn="customer_last_name",
    field="multiple_fields",
    value={
        "title": "Last Name",
        "group": "Personal Info",
        "is_read_only": False,
        "is_hidden": False,
        "description": "The last name (surname) of the customer",
        "value_type": "string",
        "possible_values": ["Smith", "Johnson", "Williams", "Brown"]
    }
)}}