A metadata cascade policy indicates if a metadata instance value should be cascaded to files and subfolders in a specific folder.
Any user with edit permisions on a folder can create metadata cascade policies for that given folder. Policies are assigned to exactly one folder and exactly one metadata instance on that folder. It should be noted that there is some delay from file upload to metadata application.
- Create Metadata Cascade Policy
- Get a Metadata Cascade Policy
- Get Metadata Cascade Policies for Folder
- Force Apply Metadata Cascade Policy
To create a new metadata cascade policy, call
MetadataCascadePolicyManager.CreateCascadePolicyAsync(string folderId, string scope, string templateKey)
.
BoxMetadataCascadePolicy metadataCascadePolicy = await client.MetadataCascadePolicyManager
.CreateCascadePolicyAsync("22222", "enterprise_11111", "templateKey");
To get information about a specific metadata cascade policy, call
MetadataCascadePolicyManager.GetCascadePolicyAsync(string policyId)
BoxMetadataCascadePolicy retrievedCascadePolicy = await client.MetadataCascadePolicyManager
.GetCascadePolicyAsync("12345", IEnumerable<string> fields = null);
To retrieve a collection of metadata cascade policies within a given folder for the current enterprise, use
MetadataCascadePolicyManager.GetAllMetadataCascadePoliciesAsync(string folderId, string ownerEnterpriseId = null, int limit = 100, string nextMarker = null, IEnumerable<string> fields = null, bool autopaginate = false)
BoxCollectionMarkerBased<BoxMetadataCascadePolicy> metadataCascadePolicies = await client.MetadataCascadePolicyManager.GetAllMetadataCascadePoliciesAsync("12345");
You can also retrieve metadata cascade policies for another enterprise with specific fields to retrieve by using
MetadataCascadePolicyManager.GetAllMetadataCascadePoliciesAsync(string folderId, string ownerEnterpriseId, int limit, IEnumberable<string> fields)
string folderId = "1111";
string ownerEnterpriseId = "2222";
BoxCollectionMarkerBased<BoxMetadataCascadePolicy> metadataCascadePolicies = await client.MetadataCascadePolicyManager.GetAllMetadataCascadePoliciesAsync(folderId, ownerEnterpriseId);
To apply a policy on a folder that already has one, use
MetadataCascadePolicyManager.ForceApplyCascadePolicyAsync(string policyId, string conflictResolution)
string policyId = "11111";
string conflictResolution = Constants.ConflictResolution.Overwrite
BoxMetadataCascadePolicy newCascadePolicy = client.MetadataCascadePolicyManager
.ForceApplyCascadePolicyAsync(policyId, conflictResolution);
The conflict_resolution field can be set to either none
which will preserve the existing value on the file, or
overwrite
, which will force-apply the cascade policy's value over any existing value.