Subform Array Processing
For sub-form fields, there are two scenarios in terms of Front-End Event:
1. Triggering fields are form fields and returned fields are sub-fields.
2. Both triggering fields and returned fields are sub-fields.
When Triggering Fields are Form Fields
When triggering fields are form fields and returned fields sub-fields, the system can receive array data and automatically create a sub-form with the same number of rows as the array. For example, the time and status (in an array) of the delivery can be automatically entered into the sub-form, and the rows in the sub-form can be automatically created according to the number of rows in the array.
When configuring through JSONPath, you can use [*] to select arrays of any length. For each row in the array, a new row will be automatically created in the sub-form.
The following is the response:
1 {
2 "showapi_res_body": {
3 "data": [
4 {
5 "context": "【America】 has received the package",
6 "time": "2020-08-19 07:52:41"
7 },
8 {
9 "context": "【Britain】 has sent the package, and next stop is 【France】",
10 "time": "2020-08-19 06:40:22"
11. },
12 {
13 "context": "【Portugal】 has received the package",
14 "time": "2020-08-19 06:20:16"
15 },
16 {
17 "context": "【Spain】 has sent the package, and next stop is 【Thailand】",
18 "time": "2020-08-19 04:16:37"
19 }
20 ]
21 }
22 }
23
If you wish to retrieve a row of the 'time' values from an array, you need to use the following data:
1 $['showapi_res_body']['data'][0]['time']
2
[0] represents the data of the first row in the indexed array. If you wish to retrieve all the 'time' values from an array and automatically create rows in a sub-form based on the number of rows in the array, you can use the following data:
1 $['showapi_res_body']['data'][*]['time']
2
When Triggering Fields are Subform Fields
When both triggering fields and returned fields are sub-fields, the situation is similar to when they are both main form fields. The triggering fields and the returned fields within the same row in the sub-form correspond to each other.
Taking Weather Forecast in the figure as an example, the city field is the triggering field. When the province and city are entered, a front-end event will be automatically triggered to query the weather and return the weather value, which will be entered into the weather field in the same row of the sub-form.
The following is the response:
1 {
2 "ret": 200,
3 “data”: {
4 "cityinfo": {
5 "provinces": "California",
6 "city": "Los Angeles",
7 "area": ""Los Angeles",
8 "id": "101190201",
9 "prov_py": "California",
10 "city_py": "Los Angeles",
11 "qh": "0510",
12 "jb": "2",
13 "yb": "214000",
14 "area_py": "Los Angeles",
15 "area_short_code": "LA",
16 "lng": "120.301663",
17 "lat": "31.574729"
18 },
19 "now": {
20 "id": "101190201",
21 "area_name": "Los Angeles",
22 "city": {
23 "night_air_temperature": "7",
24 "day_air_temperature": "13",
25 "wind_direction": "Winds shifts from northeast to north",
26 "wind_power": "less than level 3",
27 "weather": "Cloudy",
28 "weather_code": "01"
29 },
30 "detail": {
31 "time": "15:30",
32 "date": "December 1st",
33 "week": "Tuesday",
34 "temperature": "12",
35 "wind_direction": "Northeast",
36 "wind_direction_str": "NE",
37 "wind_power": "Level 2"
38 "wind_speed": "Less than 12 mph",
39 "humidity": "58%",
40 "weather": "Cloudy",
41 "weather_code": "01",
42 "weather_english": "Cloudy",
43 "qy": "1027",
44 "njd": "14.6 miles",
45 "rain": "0",
46 "aqi": "39",
47 "quality": "Good",
48 "aqi_pm25": "57",
49 "nongli": "October 17th",
50 "sun_begin": "06:40",
51 "sun_end": "16:55",
52 "so2": "68",
53 "o3": "34",
54 "co": "26",
55 "no2": "9",
56 "pm10": "1",
57 "kinect": "11",
58 "shadow_kinect": "10.0",
59 "ultraviolet_rays": "Level 2",
60 "ultraviolet_rays_status": "Low",
61 "pressure_change": "Stable",
62 "cloud_amount": "91%"
63 },
64 "update_time": 1606809680,
65 "alarm_list": []
66 }
67 },
68 "qt": 0.009
69 }
70
Then you can set the response for the Weather field as the followings:
1 $['data']['now']['detail']['weather']
2