IBM Support

When adding case document, copy the case property values to matching case document property values.

Technical Blog Post


Abstract

When adding case document, copy the case property values to matching case document property values.

Body

In a case solution, document types defined in Case Builder may share some properties with the case type. When adding a case document to a case, you may want to carry the shared property values from the case to the case document, saving the user time and potential errors. Here is a sample that shows how this can be done.

1. In Case Manager Builder, create a Case Document Type which shares several properties with a case type. 

2. Find the Case Information widget in the "Case Details" page and/or Work Details page, and edit its toolbar configuration.

3. Highlight the “Add” menu and click the button “Add Menu Item” in order to create a new menu item.

4. Add script action with the label of "Add Document with updated properties". See AddDocCopyProps highlighted below as an example.

image

5.  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);    }); 

6. In Case Client, in the case document list inside Case Information widget, choose the "Add Document with updated properties" action for adding case document, select a matched case document type which share properties with the case. 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.

image

 

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSCTJ4","label":"IBM Case Manager"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

UID

ibm11281268