IBM Support

Opening a Case After Creation

Technical Blog Post


Abstract

Opening a Case After Creation

Body

I was reminded by a recent forum question that I should create this handy Tip & Trick for my loyal readers.

The question was (basically) around 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.

Seems like a great idea. Here's how!

 

Add a Script Adapter (named Open Case in this example) to your Add Case page and wire an incoming event from the Page Container's Send New Case Information event.

 

image


In the Script Adapter, enter the following:

var self = this;
self.caseEdt = payload.caseEditable;
var coord = payload.coordination;

require(["icm/base/Constants", "icm/util/Coordination"], function(Constants, Coordination){
    coord.participate(Constants.CoordTopic.AFTERSAVE, function(context, complete, abort){
        self.checkCount = 0;
        self.statusChecker = setInterval(function(){
            self.caseEdt.retrieveAttributes(function(){
                self.checkCount++;
                var caseState = self.caseEdt.caseObject.attributes["CmAcmCaseState"];
                 if(caseState == 2){
                    clearInterval(self.statusChecker);
                    delete self.statusChecker;
                    self.onBroadcastEvent("icm.OpenCase",{
                        "caseEditable": self.caseEdt,
                        "coordination": new Coordination()
                    });
                    setTimeout(complete,1000);
                }
                if(self.checkCount > 5){
                    clearInterval(self.statusChecker);
                    delete self.statusChecker;
                    abort({"message":"Case was created, but can't open it according to wrong case status"});
                }
            });
        }, 1000);
    });
});

So what does this do you ask? It hooks the script into the page's coordination handlers so that it gets called at the appropriate time after the user clicks the "done" button on the Add Case page. Since a case can take a few seconds to be created and ready to be be opened, the script does a very short polling loop, waiting for the case to show as ready. Once it is, a simple broadcast event tells the client to open the new case's details page.

 

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

UID

ibm11280722