IBM Support

Prefiltered Case Searches

Technical Blog Post


Abstract

Prefiltered Case Searches

Body

For this entry, I thought I would connect the dots on two previous entries by describing a commonly asked use case that builds on them.

In the blog entry Preload Case List, we showed how to create a simple script, triggered by ICM 5.2's Page Open events, that is used to pre-fill the Case List when a user first logs into Case Manager Client.

Blog entry Access User Information showed how to use scripts to easily access the current user's name, ID and role. This example, in combination with the previous pre-fill one, could be used to have the Case List automatically display a list of cases that the current user owns by including a Case Owner property on the case and adding it to the search criteria.

For this use case, let's say we always want users in a specific role to only ever see cases that they own. Using the examples above, we can ensure that the Case List pre-fills with their cases; but what if they use the Search widget? How do we ensure the filter on owner is maintained there as well? Here's how:

  • Add a Case Owner property to your solution. This property value should have your user ID assigned to it for a couple of cases
  • Add a Script Adapter widget to the hidden area of the Cases page for the role where you want the filtering to always happen (remember you can set which Case page a specific role sees using the option on the main Case Type page in Case Builder).
  • Name this new Script Adapter - Filter Search
  • Wire the new Script Adapter between the Search widget's Search Cases outbound event and the Case List's Search Cases inbound event.
  • Disable the Search Cases Broadcast event by going to the Event Broadcasting tab on the Search Widget's Wiring settings. This ensures the event is only ever sent through wiring and always intercepted by our Filter Search script.
  • Enter the following script into the new Filter Search Script Adapter
/* Use your own case property here that represents case owner */
var filterPropertyName = this.solution.getPrefix()+"_CaseOwner";
var userId = ecm.model.desktop.userId;
var criterion = new ecm.model.SearchCriterion({"id": filterPropertyName, "name" : "Case Owner", "selectedOperator": "STARTSWITH", "dataType": "xs:string",
  "defaultValue" : userId, "value": userId, "values": [userId]});

/* This appends our additional search criteria onto the one from the original search */
payload.searchTemplate.searchCriteria.push(criterion);
return payload;
  • Save and deploy your solution

Now every time users in this role perform searches for cases, the results will always be filtered to just ones where their user ID is assigned as Case Owner.

 

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

ibm11281274