How to trigger action "Apply to Sub items" via ReST API?
Hi,
Is it possible to initiate "Apply to Sub items" action (i.e inherit parent metadata to children) via ReST API?
I'd like to achieve this task for a business workspace (or case). I could able to create a case with ReST API, however, its metadata is not applied to its children (sub folders). if I manually create a case it do apply the metadata to its children.
Appreciate any help or pointer. thanks in advance!
regards,
Maqsood
Comments
-
I am afraid that there is no such functionality in the CS REST API. You can use
/nodes/:id/nodes
to enumerate the children recursively and apply the modification to each one.0 -
Thanks, Ferdinand. I'm doing the same right now but wanted to do it in inheritance way. any other alternative to achieve inheritance?
0 -
Do you mean the metadata inheritance? When creating a new doucment in a folder, which has inheritable categories assigned, the categories will be applied to the document too. This happens in the CS UI automatically, but not in the CS REST API.
You need to send all categories, which you want to assign, when you create a new node by
POST .../api/v1/nodes
. You can get them by asking for the metadata needed for the node creation byGET .../api/v1/forms/nodes/create
:{ "forms": [ { "role_name": "categories", "data": {...}, "schema": {...}, ... }, ... ] }
Take the
data
object, set values of the mandatory attributes, if needed, and send it among other properties, when creating the new node:{ "name": "...", "type": ..., "parent_id": ..., "roles": { "categories": {...}, ... }, ... }
Code sample:
var baseApiURL = '.../api', userName = '...', password = '...', otcsTicket, parentNodeId = ..., newDocumentName - '...', newDocumentContent = ...; getAuthenticationTicket() .then(getCreationMetadata) .then(prepareCategories) .then(createDocument) .then(reportSuccess) .catch(reportError); function getAuthenticationTicket() { var authenticationData = new FormData(); authenticationData.append('username', userName); authenticationData.append('password', password); return fetch(baseApiURL + '/v1/auth', { method: 'post', body: authenticationData }) .then(processResponse) .then(function (response) { // Remember the ticket to be sent as 'OTCSTicket' header later otcsTicket = response.ticket; }); } function getCreationMetadata() { var url = baseApiURL + '/v1/forms/nodes/create'; return fetch(url + '?parent_id=' + parentNodeId + '&type=144', { headers: {OTCSTicket: otcsTicket} }) .then(processResponse); } function prepareCategories(metadata) { var categories = metadata.forms.find(function (form) { return form.role_name === 'categories'; }) || {}; // Mandatory attribute values have to be filled return categories.data; } function createDocument(categories) { var creationBody = { name: newDocumentName, type: 144, // Document node type parent_id: parentNodeId, roles: {categories: categories} }, creationData = new FormData(); // Workaround for the missing JSON support in the CS REST API creationData.append('body', JSON.stringify(creationBody)); creationData.append('file', newDocumentContent); return fetch(baseApiURL + '/v1/nodes', { method: 'post', headers: {OTCSTicket: otcsTicket}, body: creationData }) .then(processResponse); } function reportError(error) { console.log('Error:', error); alert(error.message); } function reportSuccess(response) { console.log('Success:', response); // The node creation returns just the new node ID alert('New document node ID: ' + response.id); } function processResponse(response) { if (!response.ok) { // Error details should be returned as JSON return response .json() .catch(function () { // If response parsing fails, return the HTTP status text var error = new Error(response.statusText); error.response = response; throw error; }) .then(function (data) { // Report the error data: {error, detail} var error = new Error(data.error); error.detail = data.detail; error.response = response; throw error; }); } return response.json(); // Default content type is JSON }
0
Categories
- All Categories
- 107 Developer Announcements
- 53 Articles
- 105 General Questions
- 141 IM Services
- 43 OpenText Hackathon
- 32 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 898 Cloud Fax and Notifications
- 76 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 118 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management