Search
Version: 1.2 | Release Date: 07/02/2024
# Introduction
The primary purpose for aiM18 system is to enhance your data management.
With aiM18, data only needs to be input once and can be viewed everywhere.
# Aim
After reading this chapter, you should be able to:
- Retrieve Data from aiM18
- Obtain Module Record Unique ID
# Scenario
Chris is IT Manager of ABC Fruit Company. He is responsible for maintaining ABC Fruit Catalog which shows imported fruits and local fruits separately.
Jane, manager from Marketing Department, contacts Chris from time to time for adding different new products.
Due to heavy workload on Chris, he often fails to release latest catalog on time.
This hindered promotion campaigns proposed by Jane.
Chris decides to solve it by using aiM18 Data Search Web Service.
# Refer to the document
The following content demonstrating how to retrieve data from aiM18.
For more detail, please refer to the complete documentation for search
services.
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://127.0.0.1:8080/jsf/rfws/search/search?stSearch=employee&startRow=1&endRow=10")
.get()
.addHeader("authorization", "Bearer MjZhZGNjMDctODVhZS00MmE0LWI3ZmEtNzRhMTQwZGZiNTY0")
.addHeader("client_id", "C-SGF2aWQncyBhcHBsaWNhdGlvbjIwMTctMDItMTAxNjc=")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
HTTP Request
GET http://[server]/jsf/rfws/search/search?stSearch=[stSearchName]&startRow=[startRow]&endRow=[endRow]
Search Parameters
Name | Type | Description |
---|---|---|
authorization | String (Header) | Required. Access Token obtained via OAuth |
client_id | String (Header) | Required. Client ID in aiM18 OAuth Applications |
stSearch | String (Query) | Required. Lookup type, such as 'employee', can be found in Data Dictionary or UDF Lookup. |
startRow | int (Query) | The start row of the search |
endRow | int (Query) | The end row of the search |
beId | long (Query) | If the search is BE specific, beId need to input |
formatId | long (Query) | Search format ID |
conds | String (Query) | Please check Condition Detail |
sorts | String (Query) | Sort Fields ,split by ";". If not ascending, please use "!"; Example:"code;!desc" |
resultFields | String (Query) | If you want to return some fields value, please this parameter. |
lookupField | boolean (Query) | If the value is true, then the result data will be no expired,no locked, and approved. |
quickSearchStr | String (Query) | If you want to use quick search ,please set this value. |
fieldDesc | boolean (Query) | If the value is true, the will return the field's name and mess value. |
viewDeleted | boolean (Query) | If you want to search the data already be deleted, Please use this value true. |
# Understanding stSearch
aiM18 Data Search Web Service relies solely on stSearch
parameter.
Within the aiM18 platform, stSearch
is also referred to as the Lookup.
Lookup is a searching scheme predefined in aiM18, it covers information of tables, sorting and table joins involved in a search.
You can obtain stSearch code
by visiting Lookup in aiM18:
In aiM18, the same module can have many different stSearch
. Some settings are predefined by the system, while others can be customized by the user.
A standard stSearch
is provided by each module, which should be suitable for most scenarios.
For instance, by visiting the Product / Material
editor, you can access the standard stSearch
used by this module.
1. Click Edit Query
2. Click Lookup
The code in brackets is the stSearch code
we want.
# Buildup Search Condition
Next we need to prepare different product lists which show imported fruits and local fruits respectively.
aiM18 Data Search Web Service allows you to provide a SQL like WHERE clause to filter data.
Assume [Series] is the field to distinguish product, we need to know its corresponding column name in Database.
aiM18 provides a convenient way for you to know the corresponding database column for a field directly on the interface.
First, you need to enable [Show Field Name] Option in the interface settings.
Next, place the cursor on the column you want to view, in this case it is [Series], and the system will display the corresponding field information.
# Get ID by Code
After collecting above information, it is easy to come up with the following condition:
For imported fruits:
seriesId=equals=IMPORT
For local fruits:
seriesId=equals=LOCAL
For all lookup fields in aiM18, When building Search Condition
, we should use record id
instead of record code
.
Record id can be obtained by using Get Id by Code Web Service.
Sample request to find Id of Series
GET `http://[server]/jsf/rfws/entity/getIdByCode/series?menuCode=series&code=IMPORT`
GET `http://[server]/jsf/rfws/entity/getIdByCode/series?menuCode=series&code=LOCAL`
Sample Response
{"withMulti":false,"id":"1","withRight":true}
{"withMulti":false,"id":"2","withRight":true}
# Summarize all the steps together
Sample request to search Products where Series = LOCAL
GET http://[server]/jsf/rfws/search/search?stSearch=pro&conds=seriesId=equals=2
Sample Response
{
"size":{
"size":4,
"values":[
{"code":"Orange","desc":"Local Orange","iRev":2,"id":8 ...},
{"code":"Banana","desc":"Local Banana","iRev":2,"id":6 ...},
{"code":"Apple","desc":"Local Apple","iRev":2,"id":5 ...},
{"code":"Peach","desc":"Local Peach","iRev":2,"id":7 ...}
]
}
}
# FAQ
1. How can I know I have to use id instead of the code?
You can check by Data Dictionary. All fields with Lookup value are storing the reference id.