Updates a metadata template.
The metadata template can only be updated if the template already exists.
The update is applied atomically. If any errors occur during the application of the operations, the metadata template will not be changed.
global
The scope of the metadata template
Value is one of global
,enterprise
properties
The name of the metadata template
A JSON-Patch specification for the changes to make to the metadata template.
The changes are represented as a JSON array of operation objects.
The data for the operation. This will vary depending on the operation being performed.
Aaron Levie
The value of a custom data entry.
option1
For operations that affect a single enum
option this defines
the key of the option that is affected.
["option1","option2","option3"]
For operations that affect multiple enum
options this defines
the keys of the options that are affected.
category
For operations that affect a single field this defines the key of the field that is affected.
["category","name"]
For operations that affect multiple fields this defines the keys of the fields that are affected.
option1
For operations that affect a single multi select option this defines the key of the option that is affected.
["option1","option2","option3"]
For operations that affect multiple multi select options this defines the keys of the options that are affected.
addEnumOption
The type of change to perform on the template. Some of these are hazardous as they will change existing templates.
Value is one of editTemplate
,addField
,reorderFields
,addEnumOption
,reorderEnumOptions
,reorderMultiSelectOptions
,addMultiSelectOption
,editField
,removeField
,editEnumOption
,removeEnumOption
,editMultiSelectOption
,removeMultiSelectOption
Returns the updated metadata template, with the custom template data included.
The request body does not contain a valid metadata schema.
The request body contains a scope that the user is not allowed to create templates for.
The requested template could not be found
An unexpected client error.
curl -X PUT https://api.box.com/2.0/metadata_templates/enterprise/blueprintTemplate/schema \
-H 'Authorization: Bearer <ACCESS_TOKEN>'
-H 'Content-Type: application/json" '
-d '[
{
"op": "editField",
"fieldKey": "category",
"data": {
"displayName": "Customer Group"
}
}
]'
var updates = new List<BoxMetadataTemplateUpdate>()
{
new BoxMetadataTemplateUpdate()
{
Op = MetadataTemplateUpdateOp.addEnumOption,
FieldKey = "fy",
Data = new {
key = "FY20"
}
},
new BoxMetadataTemplateUpdate()
{
Op = MetadataTemplateUpdateOp.editTemplate,
Data = new {
hidden = false
}
}
};
BoxMetadataTemplate updatedTemplate = await client.MetadataManager
.UpdateMetadataTemplate(updates, "enterprise", "marketingCollateral");
List<MetadataTemplate.FieldOperation> updates = new ArrayList<MetadataTemplate.FieldOperation>();
String addCategoryFieldJSON = "{\"op\":\"addField\","\"data\":{"
+ "\"displayName\":\"Category\",\"key\":\"category\",\"hidden\":false,\"type\":\"string\"}}";
updates.add(new MetadataTemplate.FieldOperation(addCategoryFieldJSON));
String changeTemplateNameJSON = "{\"op\":\"editTemplate\",\"data\":{"
+ "\"displayName\":\"My Metadata\"}}";
updates.add(new MetadataTemplate.FieldOperation(changeTemplateNameJSON));
MetadataTemplate.updateMetadataTemplate(api, "enterprise", "myData", updates);
template = client.metadata_template('enterprise', 'employeeRecord')
updates = template.start_update()
updates.add_enum_option('state', 'WI')
updates.edit_template({'hidden': False})
updated_template = template.update_info(updates)
// Add a new option to the Fiscal Year field, and un-hide the template
var operations = [
{
op: 'addEnumOption',
fieldKey: 'fy',
data: { key: 'FY20' }
},
{
op: 'editTemplate',
data: { hidden: false }
}
];
client.metadata.updateTemplate('enterprise', 'vcontract', operations)
.then(template => {
/* template -> {
templateKey: 'vcontract',
scope: 'enterprise_12345',
displayName: 'Vendor Contract',
hidden: false,
fields:
[ { type: 'date',
key: 'signed',
displayName: 'Date Signed',
hidden: false },
{ type: 'string',
key: 'vendor',
displayName: 'Vendor',
hidden: false },
{ type: 'enum',
key: 'fy',
displayName: 'Fiscal Year',
options:
[ { key: 'FY17' },
{ key: 'FY18' },
{ key: 'FY19' },
{ key: 'FY20' } ],
hidden: false } ] }
*/
});
client.metadata.updateTemplate(
scope: "enterprise",
templateKey: "personnelRecord",
operation: .reorderEnumOptions(fieldKey: "department", enumOptionKeys: ["Marketing", "Sales", "HR"])
) { (result: Result<MetadataTemplate, BoxSDKError>) in
guard case let .success(template) = result {
print("Error updating metadata template")
return
}
print("Updated metadata template with ID \(template.id)")
}