Predefined case search by using external payload in the Case Search view

You can use a predefined search by creating a custom search payload that runs a custom search by using the Case search view.

To create a custom search payload

  1. Define a variable (for example, searchPayload) of type CaseSearchPayload. CaseSearchPayload is a properly defined business object which represents the structure of a search payload. If you do not want to use a well-defined business object as type for searchPayload, define the type to be ANY.
  2. You can populate this variable in one of two ways:
    • Enable the "Has default" checkbox and provide the following script inline.
    • Use a client-side script to populate the variable
    The following example demonstrates how to populate the variable. Some lines are intentionally commented to indicate that these options in the business object are optional.
    var autoObject = {}; 
    autoObject.conditions = []; 
    autoObject.conditions[0] = { field: "CmAcmCaseState", operator: "EQUAL", value: "2" }; 
    autoObject.fieldDetails = []; 
    autoObject.fieldDetails[0] = { field: "CmAcmCaseState", dataType: "xs:integer", cardinality: "single" }; 
    autoObject.caseTypeList = [{ name: "TSP_CT1" }]; 
    // Uncomment and configure optional parameters as needed:
    // autoObject.sortArray = [{ field: "CmAcmCaseIdentifier", order: "asc" }];
    // autoObject.pagesize = 200; 
    // autoObject.andSearch = true; 
  3. The searchPayload variable is used in an event within a coach (for example, the onclick event of a button view). So, you need to add a Data view (from the UI Toolkit) to the layout and bind the searchPayload variable to it. You can then access the searchPayload within the event by using:
    var searchPayload = ${Data1}.getData();
  4. Add a button view to the layout. For in instance, name it as Search using custom payload. Write the following code to the onclick event of the button:
    /** 
     * @instance 
     * @memberof CaseSearch 
     * @method searchUsingExternalPayload 
     * @param {searchPayload} (required) searchPayload The search payload. 
     * @param {caseListControlID} (optional) The control ID of the Case List view to render results. 
     */ 
    
    // Data1 is the control id of the Data view
    var searchPayload = ${Data1}.getData(); 
    
    // Case_Search2 is the control id of the Case Search view
    var caseSearchView = ${Case_Search2}; 
    
    // use the Case Search view's public method getSearchFilterView() to get the search filter view within Case Search
    var caseSearchFilterView = caseSearchView.getSearchFilterView(); 
    
    // List Cases2 is the control id of the Case List view. It is optional.
    // searchUsingExternalPayload is a public method on Case Search view, which can be used to search cases
    // using the custom search payload 'searchPayload'.
    // When the second parameter in the searchUsingExternalPayload is not set, the search results would be displayed
    // on all instances of Case List views that might have been added to the coach.
    // When the second parameter in the searchUsingExternalPayload is set, the search results would be displayed
    // on the Case List view, whose control id is set as the second parameter.
    caseSearchFilterView.searchUsingExternalPayload(searchPayload, "List_Cases2");
  5. Click the button to run the custom search, and to populate the search results in the Case list view.

Configuration properties

Set or modify the configuration properties in the Configuration properties tab.
Table 1. Configuration properties for CaseSearchPayload
Property Description Data types Input mapping
fields A list of field names. The default lists of field names are
  • FolderName
  • CmAcmHealthIndicator
  • LastModifier
  • DateLastModified
  • CmAcmCaseTypeFolder
  • CmAcmCaseState
  • CmAcmCaseIdentifier
  • DateCreated
  • Creator
  • Id
  • CmAcmStageStatus

For an example see, Table 2

String and is a List Optional
fieldDetails A list of details about the fields which is of type CaseFieldDetail.
CaseFieldDetail is a business object that contains the following parameters:
  1. field of type String
  2. Cardinality of type String
  3. Data type of type String
Valid data types values include
  • "xs:string"(for String)
  • "xs:integer" (for Integer)
  • "xs:double" (for Float or Decimal)
  • "xs:timestamp" (for Datetime)
  • "xs:boolean" (for Boolean)
  • "xs:object" (for Object)

For example see, Table 2

CaseFieldDetail (another business object) and is a List Optional
conditions A mandatory list of conditions to be used in the search and which is of type CaseSearchCondition. CaseSearchCondition is a business object that contains the following parameters:
  1. field of type String
  2. Value of type String
  3. Operator of type String
Valid operator values are
  • "EQUAL"
  • "NOTEQUAL"
  • "CONTAINS"
  • "STARTSWITH"
  • "LESS"
  • "GREATER"

For example see, Table 2

CaseSearchCondition (another business object) and is a List Mandatory
sortArray

A list setting the sort condition and which is of type CaseSearchSortField.

CaseSearchSortField is a business object that contains the following parameters:
  1. field of type String
  2. order of type String

For example see, Table 2

CaseSearchSortField (another business object) and is a List Optional
continueFrom When searching for cases, a default of 200 cases is retrieved. If more than 200 cases are available, the continueFrom token from the previous fetch can be used to load the next 200 cases when the user navigates to the last page of the Case List table. This property is for internal use only, and is optional. String Optional
isContinuable To determine whether more cases need to be fetched beyond the initial 200. A value of true indicates that the next set of 200 cases can be fetched when the user reaches the last page of the Case list table. Boolean Optional
pagesize Specifies the number of cases to fetch during a search. If not set, the default value is 200. Integer Optional
andSearch To determine how conditions in the conditions array are combined. If set to true, the conditions use the AND operator. If set to false, the OR operator is used. Boolean Optional
caseTypeList A property of the type List that contains a list of Case Types. If not set, the runtime automatically populates this list with all available case types. String and is a List Optional
Table 2. Examples of configuration properties for CaseSearchPayload
Property Example
fields
var fields =["FolderName","CmAcmHealthIndicator","LastModifier","DateLastModified","CmAcmCaseTypeFolder",
"CmAcmCaseState","CmAcmCaseIdentifier","DateCreated","Creator","Id","CmAcmStageStatus"];
fieldDetails
var fieldDetails = []; 
fieldDetails[0] = { field: "CmAcmCaseState", dataType: "xs:integer", cardinality: "single" };
conditions
var conditions = []; 
var conditions[0] = { field: "CmAcmCaseState", operator: "EQUAL", value: "2" }; 
sortArray
var sortArray = []; sortArray[0] = { field: "CmAcmCaseIdentifier", order: "asc"};
Table 3. Configuration properties for CaseFieldDetail
Property Description Data types
field

The name of the case property.

String
cardinality

Either single or multi.

String
Data type

The possible values

  • "xs:string"(for String)
  • "xs:integer" (for Integer)
  • "xs:double" (for Float or Decimal)
  • "xs:timestamp" (for Datetime)
  • "xs:boolean" (for Boolean)
  • "xs:object" (for Object)
 
Table 4. Configuration properties for CaseSearchCondition
Property Description Data types
field

The name of the case property.

String
value

The value to search for (string, number, datetime, or Boolean).

 
operator

Valid values include EQUAL, NOTEQUAL, CONTAINS, STARTSWITH, LESS, GREATER.

 
Table 5. Configuration properties for CaseSearchSortField
Property Description Data types
field

The name of the case property.

String
order Sorting order (ascending or descending).  
Additional resources
For more information about how to create a coach or page, see Building coaches.
For more information about standard properties (General, Configuration, Positioning, Visibility, and HTML Attributes), see View properties. For other UI views, see UI toolkit.