MetadataTemplates
Create, update, delete and query the Metadata Templates in Box
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
MetadataTemplates can be deleted by providing Scope and TemplateKey and issuing a DELETE statement.
DELETE FROM MetadataTemplates WHERE Scope='enterprise' AND TemplateKey='TestTemplate'
Columns
Name | Type | ReadOnly | Description |
Id [KEY] | String | True |
The ID of the metadata template. |
TemplateKey | String | False |
A unique identifier for the template. This identifier is unique across the scope of the enterprise to which the metadata template is being applied, yet is not necessarily unique across different enterprises |
CopyInstanceOnItemCopy | Boolean | False |
Whether or not to copy the metadata for a file or folder when an it is copied. |
DisplayName | String | False |
The display name of the template |
FieldsId [KEY] | String | True |
The Unique Id of the Metadata Template field |
FieldsKey | String | False |
A unique identifier for the field. The identifier must be unique within the template to which it belongs. |
FieldsDisplayName | String | False |
The display name of the field as it is shown to the user in the web and mobile apps. |
FieldsType | String | False |
The type of field |
FieldsDescription | String | False |
A description of the field |
FieldsisHidden | Boolean | False |
Whether this field is hidden in the UI for the user and can only be set through the API instead. |
FieldsOptions | String | False |
A list of options for this field. This is used in combination with the enum and multiSelect field types. |
TemplateisHidden | Boolean | False |
Defines if this template is visible in the Box web app UI, or if it is purely intended for usage through the API |
Scope | String | False |
The scope of the metadata template. |
Type | String | True |
Type of the template. 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 |
The type of change to perform on the template. Some of these are hazardous as they will change existing templates. The allowed values are editTemplate, addField, reorderFields, addEnumOption, reorderEnumOptions, reorderMultiSelectOptions, addMultiSelectOption, editField, removeField, editEnumOption, removeEnumOption, editMultiSelectOption, removeMultiSelectOption. |
EnumOptionKey | String |
Update Only: For operations that affect multiple enum options this defines the keys of the options that are affected. |
MultiSelectOptionKey | String |
Update Only: For operations that affect multiple multi select options this defines the keys of the options that are affected. |
FieldsAggregate | String |
To insert more than one fields in the Template. The accepted columns are FieldsDisplayName, FieldsType, FieldsDescription, FieldsKey, FieldsisHidden, FieldsOptions |