<< Click to Display Table of Contents >> Update ECM Metadata |
Overview
By default, a document uploaded through the ECM control will allow users to manually edit this information.
However and when using ECM integration, there are scenarios in which you may want to automatically map business information into a document to be stored at the ECM.
To update the metadata, use the following function:
CHelper.UpdateECMMetadata(Me, data, XPath)
The following attributes are needed:
•Me: this parameter is fixed.
•data: metadata structure.
•XPath: corresponds to the data model's file attribute.
Example
The examples below illustrates the methods to use in a rule which automatically maps information into the uploaded document.
Upload File
In this example, we map information already contained in our case into the Title and Description metadata.
Our ECM file upload is set in MyProcessEntity.MyFileAttribute.
var XPath = "MyProcessEntity.MyFileAttribute"; //this XPath corresponds to the data model's file attribute
var metadataHash = new Hashtable(); //this creates a temporary structure to hold metadata
metadataHash.Add("Title", <MyProcessEntity.CustomerNameAttribute>);
metadataHash.Add("Description", <MyProcessEntity.SomeDescriptionAttribute>);
//do this to set each metadata field
var tmpFileAttribute = Me.getXPath(XPath); //this obtains all information in the file attribute
for(var i=0; i < tmpFileAttribute.size(); i++) //iteration is done, as this file could contain more than 1 document
{
var tmpFile = tmpFileAttribute.get(i); //this obtains the actual document
var idFileUpload = tmpFile.getXPath("id"); //this obtains the id for the actual document
var completeXpath = XPath + "[id=" + idFileUpload + "]"; //this builds the complete XPath to reference each document
CHelper.UpdateECMMetadata(Me, metadataHash, completeXpath); //method to map metadata
}
Files on a table
In this example, our rule is set outside of a table, but we will map metadata for all uploads inside of a table.
This means that we map Title and Description metadata (information already contained in our case), for an ECM file upload which is contained in MyProcessEntity.MyCollection.MyFileAttribute. (as a column of a table).
var XPath = "MyFileAttribute"; //this XPath corresponds to the data model's file attribute
var xPathContext = "MyProcessEntity.MyCollection"; //this XPath corresponds to the context of the actual table
var metadataHash = new Hashtable(); //this creates a temporary structure to hold metadata
metadataHash.Add("Title", <MyProcessEntity.CustomerNameAttribute>);
metadataHash.Add("Description", <MyProcessEntity.SomeDescriptionAttribute>);
var List = Me.getXPath(xPathContext); //this obtains the information in the table
var Array = CHelper.GetValueAsCollection(List);
for (var j=0; j < Array.size(); j++) //iteration is done for the records of that table
{
var tmpRecord = Array.get(j); //this obtains the actual record
var FileAttrib = tmpRecord.getXPath(XPath); //this obtains all information in the file attribute
var idRecord = tmpRecord.getXPath("id"); //this obtains the id for the actual record
for(var i=0; i < FileAttrib.size(); i++) //iteration is done, as this file could contain more than 1 document
{
var SubFile = FileAttrib.get(i); //this obtains the actual document of that record
var idFileUpload = SubFile.getXPath("id"); //this obtains the id for the actual document
var completeXpath = xPathContext + "[id=" + idRecord + "]." + XPath + "[id=" + idFileUpload + "]"; //this builds the complete XPath to reference each document
CHelper.UpdateECMMetadata(Me, metadataHash, completeXpath); //method to map metadata
}
}
Last Updated 1/6/2022 4:18:28 PM