MetadataTemplates
Contains reusable metadata templates that define structured fields which can be applied to files and folders.
Table Specific Information
Select
You can retrieve information about the Metadata Template.
SELECT * FROM MetadataTemplates;
You can also retrieve the information of any Template in your enterprise:
SELECT * FROM MetadataTemplates WHERE Id = 'e93746cc-03f6-4dee-ab45-01834989950c';
Insert
You can insert Metadata Template for your enterprise.
Insert a single field to the Template.
INSERT INTO MetadataTemplates (DisplayName, Scope, FieldsDisplayName, FieldsType) VALUES ('TestTemplate', 'enterprise', 'TestField', 'string');
Insert multiple fields to the Template.
INSERT INTO MetadataFields#TEMP (FieldDisplayName, FieldType, FieldOptions) VALUES ('Industry', 'enum', 'Technology, HealthCare');
INSERT INTO MetadataFields#TEMP (FieldDisplayName, FieldType) VALUES ('Contact Role', 'string');
INSERT INTO MetadataTemplates (DisplayName, Scope, FieldsAggregate) VALUES ('TestTemplate', 'enterprise', 'MetadataFields#TEMP');
Update
Add field to the existing Template.
UPDATE MetadataTemplates SET Op = 'addField', FieldsKey = 'category', FieldsDisplayName = 'Category', FieldsisHidden = false, FieldsType = 'string' WHERE Scope = 'enterprise' AND TemplateKey = 'TestTemplate';
Update Fields in the Template.
UPDATE MetadataTemplates SET Op = 'editField', FieldsKey = 'Category', FieldsDescription = 'The Product Category' WHERE Scope = 'enterprise' AND TemplateKey = 'TestTemplate';
Reorder Fields in the Template.
UPDATE MetadataTemplates SET Op = 'reorderFields', FieldsKey = 'Category,Industry,Contact' WHERE Scope = 'enterprise' AND TemplateKey = 'TestTemplate';
Remove Fields from the Template.
UPDATE MetadataTemplates SET Op = 'removeField', FieldsKey = 'Industry' WHERE Scope = 'enterprise' AND TemplateKey = 'TestTemplate';
Add Enum Options to the EnumField.
UPDATE MetadataTemplates SET Op = 'addEnumOption', FieldsKey = 'Industry', EnumOptionKey = 'AL' WHERE Scope = 'enterprise' AND TemplateKey = 'TestTemplate';
Reorder Enum Options in the EnumField.
UPDATE MetadataTemplates SET Op = 'reorderEnumOptions', FieldsKey = 'industry', EnumOptionKey = 'AL,AK,AR,N/A' WHERE Scope = 'enterprise' AND TemplateKey = 'TestTemplate';
Update Enum Options in the EnumField. Specify Present value, New value in the EnumOption column, separated with comma.
UPDATE MetadataTemplates SET Op = 'editEnumOption', FieldsKey = 'industry', EnumOptionKey = 'N/A,Outside USA' WHERE Scope = 'enterprise' AND TemplateKey = 'TestTemplate';
Remove Enum Options from the EnumField.
UPDATE MetadataTemplates SET Op = 'removeEnumOption', FieldsKey = 'industry', EnumOptionKey = 'Outside USA' WHERE Scope = 'enterprise' AND TemplateKey = 'TestTemplate';
Delete
Delete metadata templates by specifying Scope and TemplateKey.
DELETE FROM MetadataTemplates WHERE Scope = 'enterprise' AND TemplateKey = 'TestTemplate';
Columns
| Name | Type | ReadOnly | Description |
| Id [KEY] | String | True |
Unique identifier assigned to the metadata template. |
| TemplateKey | String | False |
A unique key that identifies the metadata template within the enterprise. This key is unique inside a single enterprise but might differ across enterprises. |
| CopyInstanceOnItemCopy | Boolean | False |
Indicates whether metadata applied to a file or folder should be copied when the item itself is copied. |
| DisplayName | String | False |
The user-friendly name of the metadata template as shown in the Box web and mobile apps. |
| FieldsId [KEY] | String | True |
Unique identifier assigned to a specific field within the metadata template. |
| FieldsKey | String | False |
A unique key for the field within its metadata template, required to distinguish it from other fields. |
| FieldsDisplayName | String | False |
The display name of the field as shown to users in the Box web and mobile apps. |
| FieldsType | String | False |
The type of the metadata field, such as string, enum, or multiSelect. |
| FieldsDescription | String | False |
A description of the metadata field's purpose or usage. |
| FieldsisHidden | Boolean | False |
Indicates whether the field is hidden in the user interface and can only be set programmatically through the API. |
| FieldsOptions | String | False |
A list of allowed options for the field, used with enum and multiSelect field types. |
| TemplateisHidden | Boolean | False |
Indicates whether the template is visible in the Box web application or restricted to API usage only. |
| Scope | String | False |
Defines the scope of the template, such as enterprise-wide or global. |
| Type | String | True |
The object type for the template. This value is always metadata_template. |
Pseudo-Columns
Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.
| Name | Type | Description |
| Op | String |
Specifies the type of change to apply to the template, such as add or remove. Some changes might alter existing templates and should be used with caution. The allowed values are editTemplate, addField, reorderFields, addEnumOption, reorderEnumOptions, reorderMultiSelectOptions, addMultiSelectOption, editField, removeField, editEnumOption, removeEnumOption, editMultiSelectOption, removeMultiSelectOption. |
| EnumOptionKey | String |
Used in update operations to define the keys of the enum options that are affected. |
| MultiSelectOptionKey | String |
Used in update operations to define the keys of the multi-select options that are affected. |
| FieldsAggregate | String |
Allows inserting multiple fields into a template at once. Accepted columns include FieldsDisplayName, FieldsType, FieldsDescription, FieldsKey, FieldsisHidden, and FieldsOptions. |