Sometimes, there is requirement that, when user add document in icm user has to fill document properties values again that are however same with case properties values. Following are the steps to achieve the requirement Copy Case properties values to document class:
- Open Case Manager Builder first, create a Case Document Type, and add properties with a case type.
- Go to the Pages Section in Case Manager Builder, find the Case Information widget on the “Case Details” page or “Work Details” page, and edit its toolbar configuration.
- Add script action with the label of “Add Document with updated properties” as described above.
- In the script action’s configuration, put the following script in the Execute section.
var self = this;
require([“ecm/model/Teamspace”, “ecm/widget/dialog/AddContentItemDialog”, “dojo/aspect”, “dojo/_base/array”, “dojo/_base/lang”, “icm/model/properties/controller/ControllerManager”],
function(Teamspace, AddContentItemDialog, aspect, array, lang, ControllerManager) {
var caseEdt = self.getActionContext(“Case”)[0];
var parentFolder = self.getActionContext(“CurrentFolder”)[0];/*Create the add document dialog*/ var addContentItemDialog = new AddContentItemDialog(); var _propagateCaseProps = function() { var contentItemPropertiesPane = addContentItemDialog.addContentItemPropertiesPane; /*Fetch the properties from document properties pane*/ var allProps = contentItemPropertiesPane.getPropertiesJSON(); /*Match the doc propertis with case properties, and set value*/ var propsCtrl = ControllerManager.bind(caseEdt); array.forEach(allProps, function(entry, i) { var propName = entry.name; var propCtrl = propsCtrl.getPropertyController(propName); if (propCtrl) { var casePropValue = propCtrl.get("value"); if (entry.dataType === "xs:boolean") {/*Convert the case property control's value to case document property control's vaule*/ casePropValue = (casePropValue == true) ? 1 : 0; } else if (entry.dataType === "xs:timestamp") { casePropValue = casePropValue.valueOf(); } contentItemPropertiesPane.setPropertyValue(propName, casePropValue); } }); ControllerManager.unbind(caseEdt); }; var widgetAttrs = null; var widget = self.getWidget(); if (widget.parentWidget && widget.parentWidget.getWidgetAttributes) { widgetAttrs = widget.parentWidget.getWidgetAttributes(); }else { widgetAttrs = widget.getWidgetAttributes(); } /*Check if the the solution document type filtering is on in the case information widget's configuration*/ var filterOn = widgetAttrs.getItemValue("filterDocumentTypes"); if(filterOn){ var currSolution = caseEdt.getCase().caseType.getSolution(); currSolution.retrieveDocumentTypes(function(docTypes) { var dcList = null; if (docTypes && docTypes.length > 0) { dcList = new Teamspace({ repository: parentFolder.repository, name: parentFolder.repository.name, type: Teamspace.RUNTIME, addAllowAllClasses: false, contentClasses: docTypes, defaultClass: null }); } /*Show the add document dialog*/ addContentItemDialog.show(parentFolder.repository, parentFolder, true, false, null, dcList, false, null, true); }); }else{ /*Show the add document dialog*/ addContentItemDialog.show(parentFolder.repository, parentFolder, true, false, null, null, false, null, true); } /*Hook to the complete rendering document properties*/ aspect.after(addContentItemDialog.addContentItemPropertiesPane, "onCompleteRendering", _propagateCaseProps);
});
- In Case Manager Client, in the case document list inside Case Information widget, choose the “Add Document with updated properties” action for adding case document.
- You will see that the document properties will be filled with the values from the properties from the case to which the document was added as described below:
In addition, please visit https://www.ibm.com/developerworks/community/blogs/e8206aad-10e2-4c49-b00c-fee572815374/entry/when_adding_case_document_copy_the_case_property_values_as_the_case_document_property_values?lang=en