IBM Case Manager (ICM), IBM Case Manager Client

Open Work Detail Page After Create a Case

September 11, 2020

There is a requirement that, whether the user could be taken to the case immediately after the Add Case action so that they could continue to add more content without having to go back to the case list and search for it. To implement this, please visit this tech note: https://www.ibm.com/support/pages/opening-case-after-creation

Similarly, you can also open work detail page after create a case by doing the following steps:

  • Add a script adaptor widget to the hidden widgets area on Add Case page and rename it some distinguish.
  • Wire an inbound event from the Page Container’s Send new case information to the Script adaptor’s Receive Event.
ibm-case-manager-widget-wiring
  • Go to script adator settings, and put the following code:
var self = this;
var coord = payload.coordination;

require(["icm/base/Constants", "icm/util/Coordination"],
    function (Constants, Coordination) {
        console.log("Open new case begin");
        self.caseEdt = payload.caseEditable;
		
		// replace In-basket name in which case created. 
        var workListName = "SDW_My Work";
		
        console.log("part to aftersave");
        console.log(Constants.CoordTopic.AFTERSAVE);
        console.log(coord);
        coord.participate(Constants.CoordTopic.AFTERSAVE, function (context, complete, abort) {
            debugger;
            //Entered Form Info
            console.log("part call back");
            self.checkCount = 0;
            self.caseCreatedFlag = false;
            self.statusChecker = setInterval(function () {
                self.caseEdt.retrieveAttributes(function () {
                    self.checkCount++;
                    console.log("check case states");
                    console.log("checkCount :" + self.checkCount);
                    var caseState = self.caseEdt.caseObject.attributes["CmAcmCaseState"];
                    console.log("caseState : " + caseState);
                    //Working (2) // Completed (3)
                    if (caseState == 2 && !self.caseCreatedFlag) {
                        self.caseCreatedFlag = true;
                        clearInterval(self.statusChecker);
                        delete self.statusChecker;
var caseUniqueField = self.caseEdt.caseObject.attributes["CmAcmCaseIdentifier"];
                        subsVar = {
                            "substitution_vars": [{
                                "name": "CmAcmCaseIdentifier",
                                "value": [caseUniqueField],
                                "type": "xs:string"
                            }]
                        };
                        function retrieveAttributes(myItemFull) {
                            console.log("Inside Retrieve Attributes");
                            myEdit = myItemFull.createEditable();
                            payload = {};
                            payload.workItemEditable = myEdit;
                            payload.coordination = new icm.util.Coordination();
                            payload.UIState = new dojo.Stateful();
                            payload.openInNewTab = false;
                            broadcastResult = self.onBroadcastEvent(
                                "icm.OpenWorkItem", payload);
                            console.log(broadcastResult);
                            setTimeout(complete, 1000);
                        }
                        var workitem;
                        function retrieveWorkItem(payload) {
                            console.log("Retrieve Work Item");
                            workitem = payload;
                            retrieveWorkItemFlag = false;
                            // Search for the specific workItem
                            console.log("Found " + workitem.fetchCount + " item(s) in the work basket");
                            for (var i = 0; i < workitem.fetchCount; i++) {
                                retrieveWorkItemFlag = true;
                                myItem = icm.model.WorkItem.fromWorkItem(workitem.getItem(i));
                                myItem.lockStep(retrieveAttributes);
                                //systemResponseDialogHelper.hideLoadingIndicator();
                                return;
                            }
console.log("Could not find Step, Retrying in 1 second");
                            if (!retrieveWorkItemFlag) {
                                setTimeout(function () {                                   selectedWorkList.retrieveWorkItems(
                                        retrieveWorkItem, null,
                                        false, true, null,
                                        "(CmAcmCaseIdentifier=:A)",
                                        subsVar, null);
                                }, 1000);
                            }
                        }
                        function retrieveWorkList(payload) {
                            console.log("Retrieve Work List");
                            debugger;
                            worklist = payload;
                            if (worklist != null) {
                                for (var i = 0; i < worklist.length; i++) {
                                    debugger;
                                    console.log("Work List Name: " + worklist[i].auth_name);
                                    if (worklist[i].auth_name == workListName) {
                                        selectedWorkList = worklist[i];
                                        selectedWorkList.retrieveWorkItems(
                                            retrieveWorkItem,
                                            null, false,
                                            true, null,
                                            "(CmAcmCaseIdentifier=:A)",
                                            subsVar, null);
                                        break;
                                    }
                                }
                                console.log("End of WorkList Search");
                            } else {
                                console.warn("No Worklist Found");
                            }
                        }
                        self.getRole().retrieveWorklists(retrieveWorkList);
                    }
                    if (self.checkCount > 5 && !self.caseCreatedFlag) {

                        console.log("Can't open the case");

                        clearInterval(self.statusChecker);

                        delete self.statusChecker;

abort({ "message": "Case Created. Please close this tab and find the case in your in-basket." });
                    }
                });

            }, 2500);
        });
    });
console.log("Open new case end");

Note: please change the in-basket name var workListName = “SDW_My Work”

  • Save and close the solution once you applied these changes.
  • Deploy the solution and test the case. You will see, right after creating a new case, work detail page will be opened without go back to in-basket as described in these screenshots:
ibm-case-manager-script-adapter
open-work-detail-page-after-create-a-case

You Might Also Like

2 Comments

  • Reply Aditya Kumar October 8, 2020 at 11:22 am

    Hi,
    What are casestate 0 & 1 denotes?
    2 workong
    3 completed

    • Reply Junaid Azam October 9, 2020 at 3:03 pm

      Hi Aditya,

      This is the sequence:

      Case Created 0
      Initialized 1
      Working 2
      Complete 3
      Failed 4

    Leave a Reply

    error

    Subscribe