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
- 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.
- 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
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; - The searchPayload variable is used in an event within a coach (for
example, the
onclickevent of a button view). So, you need to add aDataview (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(); - Add a button view to the layout. For in instance, name it as
Search using custom payload. Write the following code to theonclickevent 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"); - 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.
| Property | Description | Data types | Input mapping |
|---|---|---|---|
| fields | A list of field names. The default lists of field names are
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:
For example see, Table 2 |
|
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:
For example see, Table 2 |
|
Mandatory |
| sortArray |
A list setting the sort condition and which is of type CaseSearchSortField is a business object that contains the following parameters:
For example see, Table 2 |
|
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 |
| Property | Example |
|---|---|
| fields |
|
| fieldDetails |
|
| conditions |
|
| sortArray |
|
| Property | Description | Data types |
|---|---|---|
| field |
The name of the case property. |
String |
| cardinality |
Either single or multi. |
String |
| Data type |
The possible values
|
| 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. |
| 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.