How can I get cases another solution in IBM Case Manager?

892 views Asked by At

I have two solutions. How can I get cases another solution?

I think that icm.util.SearchPayload allows you to get the cases of the current solution.

    buildPayload: function (values) {
            if (!values) {
                    console.log("An invalid values is received!");
                    return;
            }

            var searchPayload = new icm.util.SearchPayload();
            // CURRENT SOLUTION
            var solution = this.widget.solution;
            var params = {};
            params.ObjectStore = solution.getTargetOS().id;

            params.ceQuery = "SELECT t.[FolderName], t.[LastModifier], t.[DateLastModified], t.[CmAcmCaseTypeFolder], t.[CmAcmCaseState], t.[CmAcmCaseIdentifier], t.[DateCreated], t.[Creator], t.[Id], t.[ContainerType], t.[LockToken], t.[LockTimeout],  t.[ClassDescription], t.[DateLastModified], t.[FolderName] FROM [CmAcmCaseFolder] t where ";
            params.ceQuery += "t.[CmAcmCaseIdentifier] LIKE '%%' AND ";

            for (var key in values) {
                    var attr = values[key].attr;
                    if (attr.dataType === "xs:string") {
                            params.ceQuery += "t.[" + key + "] LIKE '%" + values[key].value + "%' AND ";
                    } else {
                            params.ceQuery += "t.[" + key + "] = " + values[key].value + " AND ";
                    }
            }

            params.ceQuery = params.ceQuery.substring(0, params.ceQuery.length - 4);

            var that = this;
            this.widget.solution.retrieveCaseTypes(function (types) {
                    console.log(params.ceQuery);
                    params.caseType = types && types.length > 0 && types[0].name; // default to the first case type
                    params.solution = solution;

                    searchPayload.setModel(params);
                    var payload = searchPayload.getSearchPayload(function (payload) {
                            that.widget.onBroadcastEvent("icm.SearchCases", payload);
                            console.log(payload);
                            that.displayPayload(payload);
                    });
                    //
            });
    },

May be

ecm.model.desktop.retrieveSolutions?

Thank you!

1

There are 1 answers

0
Shelepaev Oleg On BEST ANSWER

Solution:

define(["dojo/_base/declare", 
"dojo/_base/lang",
"dojo/_base/array",
"icm/base/Constants",
"icm/model/Case",   
"ecm/LoggerMixin",
"icm/model/_DesktopMixin"], 
function(declare, lang, array, Constants, Case, LoggerMixin, _DesktopMixin){
    return declare("icm.custom.pgwidget.customSearchWidget.CustomWidgetContentPaneEventListener", [LoggerMixin, _DesktopMixin], {

        searchTemplate: null,
        widget: null,

        constructor: function(widget){
            this.widget = widget;
        },

        buildPayload: function(values) {
            if(!values) {
                console.log("An invalid values is received!");
                return;
            }

            console.log("retrieveSolutions");
            var that = this;
            this.retrieveSolutions(function(solutionList) {
                array.forEach(solutionList, function(solution) {
                    if (solution.id === "CBFPSFED_57_2") {
                        console.log("CBFPSFED_57_2");

                        var searchPayload = new icm.util.SearchPayload();

                        var params = {};
                        params.ObjectStore = solution.getTargetOS().id;

                        params.ceQuery = "SELECT t.[FolderName], t.[LastModifier], t.[DateLastModified], t.[CmAcmCaseTypeFolder], t.[CmAcmCaseState], t.[CmAcmCaseIdentifier], t.[DateCreated], t.[Creator], t.[Id], t.[ContainerType], t.[LockToken], t.[LockTimeout],  t.[ClassDescription], t.[DateLastModified], t.[FolderName] FROM [CmAcmCaseFolder] t where ";
                        params.ceQuery += "t.[CmAcmCaseIdentifier] LIKE '%%'  AND t.[JR572_name] LIKE '%%%'";

                        solution.retrieveCaseTypes(function(types) {
                            console.log(types);             
                            console.log(params.ceQuery);
                            params.caseType = types && types.length > 0 && types[0].name; // default to the first case type
                            params.solution = solution;

                            searchPayload.setModel(params);
                            var payload = searchPayload.getSearchPayload(function(payload) {
                                that.widget.onBroadcastEvent("icm.SearchCases", payload);
                                console.log("buildPayload");
                                console.log(payload);
                            });
                        });
                    }
                });
            });
        },

        _eoc_: null
    });
});

Key points:

icm/model/_DesktopMixin

this.retrieveSolutions(function(solutionList) {