IBM Support

Getting the next work item with custom logic after completing a work item

Technical Blog Post


Abstract

Getting the next work item with custom logic after completing a work item

Body

image

 

Johnson Liu is a Software Engineer with IBM Software Group in the United States. For IBM Case Manager, he developed various early training workshops, white papers, and code samples. Johnson has expertise and supports customers in the areas of widget development, user interface, and solution deployment and conversion. Johnson has a Bachelor of Science degree from the University of California in Business Information Management.

 

In this blog entry, I will show you how to customize IBM Case Manager V5.2 to use custom logic and retrieve the next work item automatically for the Work Details page. This is typically used when the solution must automatically present the next work item in the work queue based on some custom logic when a case worker completes a work item.

Special note: This customization scenario uses the icm/util/workItemHandler class that has yet to be published on the IBM Case Manager JavaScript API reference documentation on the IBM Case Manager V5.2 Information Center. It will be published after fix pack 1 has been released for IBM Case Manager V5.2. This class will allow application developers to handle work items by examining the state or to retrieve the next work item in the In-basket widget with the handleNextWorkItem(icmWorkItem) and handleWorkItem(icmWorkItem, isNext) functions. This customization scenario and the Opening Multiple Work Items customization scenario in the IBM Redbooks publication, Advanced Case Management with IBM Case Manager are great examples of how to use icm/util/workItemHandler.

 

Getting the next work item with custom logic after completing a work item

This customization scenario allows the user to complete a work item, then have some custom logic to retrieve the next work item automatically. The custom logic in this specific example retrieves the next work item that has the same step name as the one that was opened from the In-baskets widget.

This customization scenario utilizes the get next option that is available in the Work Item Toolbar widget’s Complete action. The Complete action in the Work Item Toolbar widget can be enabled to automatically get the next work item. This retrieves the next work item when the case worker clicks on this Complete button. This customization extends off of this standard feature in IBM Case Manager and adds custom logic.

image

The Work Item Toolbar widget’s Complete action

Specifically, for the Customer Complaints solution, if a case worker is of the Specialist Role and opens the only Review Product Compliant work item in the work queue and the rest of the work items in the queue for the Specialist role are Review Non-Product Compliant work items, then the work details page will notify the case worker that there are no more work items to retrieve. We will discuss how to customize the solution below.

  1. Open the page or custom Work Details page in Page Designer. In this example, we will use the Work Details page.
  2. Open the Edit Wiring window and select the Page Container widget. Click on the Event Broadcasting tab and un-check the box for the Send work item. This ensures that the custom script we add in later broadcasts this event, instead of the page.
  3. Click the Edit Settings icon on the Work Item Toolbar widget. Click on the Toolbar tab and double click on the Complete toolbar label to edit it.
  4. Check the box labeled Automatically get the next work item. This enables the Complete button on the work details page to retrieve the next work item.
  5. Drag and drop the Script Adapter widget from the widget palette area to the main layout area.
  6. Click the Edit Settings icon on the Script Adapter widget and insert the script below into the JavaScript text area. This script is a sample that requires the next work item to have the same step name as the first work item opened from the In-baskets widget directly. This may be changed or modified if you want to retrieve the next work item using different critieria.

Sample script to process a work item

 

var widget = this;

 

require([

         "dojo/_base/declare",

         "dojo/_base/lang",

         "icm/util/WorkItemHandler",

], function(

        declare,

        lang,

        WorkItemHandler

) {

if(payload !== null){

    var workItemEditable = payload.workItemEditable;

    var UIState = payload.UIState;

    if ( workItemEditable !== null) {

         /*If the current work item is not gotten from get next function, just show it*/

         var stepName = workItemEditable.getStepName();

         if(UIState !== null && UIState.get("GetNext") === true){

         /*do any rules based on business logic*/

         

        if ( widget.lastWorkItemStepName && stepName !== widget.lastWorkItemStepName){

        /* if the work item is not expected. We always need to handle the work item with same stepName for handling */

             var icmWorkitem = workItemEditable.getWorkItem();

             icmWorkitem.abortStep(lang.hitch(this, function(){

                  var handler = new WorkItemHandler(widget);

                  handler.handleNextWorkItem(icmWorkitem);

             }));

         }else{

                widget.lastWorkItemStepName = stepName;

                widget.onBroadcastEvent("icm.SendWorkItem", payload);     

         }

     }else{

            widget.lastWorkItemStepName = stepName;

            widget.onBroadcastEvent("icm.SendWorkItem", payload);     

     }

    }

}

});

return null;

  1. Click the Edit Wiring icon on the Script Adapter widget and enter the following values under the section labeled Incoming Events for the Script Adapter:
    • Source widget: Page Container
    • Outgoing event: Send work item
    • Incoming event: Receive event payload
  1. Click the OK button to save the changes to the Script Adapter widget. Then save the changes to the page, deploy the changes to the solution.
  2. Open Case Manager Client to validate this customization scenario. To validate, open a work item directly from the In-baskets widget to view the work item on the Work Details page. Then, complete the work item and notice that the next work item with the same step name comes up automatically. When there are no more work items with the same name in the In-baskets widget, there is a dialog that comes up.

 

Special Thanks to the following people who have contributed to this BLOG entry post:

  • Xiao Ji Tian
  • Ying Ming Gao
  • Eugene Rozhdestvensky

 

Additional references

For IBM Case Manager V5.2 related blog posts, see:

 

For IBM Case Manager V5.2 Redbooks publication, see:

 

[{"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

ibm11281184