1

List of Units

Тема: List of Units

Hi All,

I have following problem.

I have got a list of units from API. That is totally fine.
I do store those data in db.
I am also saving information which is stored in the field [pflds] such as brand, year, model, registration plate etc, and all are sent in arrays.

However, not all units have filled in the information and so sometimes there is an array of 5 elements, sometimes 2 elements and I can't save the information easily.

I just wanna say

  • array 1 is model, store in column model
  • array 2 is brand, store in column brand
  • array 3 is registration plate, store in column registration plate

rather then creating some complicated condiftions if the array "x" contains "name:model" then store it in column model & etc.

Is there a way to get the full array of [pflds] and its all information no matter whether the field is empty or not?
Also, there is a fact that I do not know what information I can actually get.

2

List of Units

Re: List of Units

Hello!

if you apply flag =  8388608 to get profile fields in response you canl see parameter  without any information  (empty JSON) like for example from request search items
{"searchSpec":{"itemsType":"avl_unit","propName":"sys_name","propValueMask":"*test_tony*","sortType":"sys_name","propType":"","or_logic":"0"},"dataFlags":8388608,"totalItemsCount":1,"indexFrom":0,"indexTo":0,"items":[{"pflds":{},"pfldsmax":-1}]}

  - so there is not any in unit properties

or you will get information in parameter "pflds"  - field name and its value

If you need to get all possible field name, you can get information once from unit which properties profile field are completed full.

Diana Cheley
Wialon Hosting Expert
Gurtam
3

List of Units

(22/01/2020 17:20:40 отредактировано jiri.mechura)

Re: List of Units

Thank you for your reply.

I am using the flag you mentioned.
My problem is that the data are not consistent. As you can see in json below:

           [6] => Array
                (
                    [pflds] => Array
                        (
                            [1] => Array
                                (
                                    [id] => 1
                                    [n] => registration_plate
                                    [v] => xxxxxx
                                )

                            [2] => Array
                                (
                                    [id] => 2
                                    [n] => vehicle_type
                                    [v] => xxxxx
                                )

                            [3] => Array
                                (
                                    [id] => 3
                                    [n] => brand
                                    [v] => xxxx
                                )

                        )

                    [pfldsmax] => 0
                )

            [7] => Array
                (
                    [pflds] => Array
                        (
                            [1] => Array
                                (
                                    [id] => 1
                                    [n] => vehicle_type
                                    [v] => Трактор
                                )

                            [2] => Array
                                (
                                    [id] => 2
                                    [n] => registration_plate
                                    [v] => xxxxx
                                )

                            [3] => Array
                                (
                                    [id] => 3
                                    [n] => brand
                                    [v] => John Deere
                                )

                        )

                    [pfldsmax] => 0
                )

Once the registration plate is

Array -> [6] -> [1] -> [n] registration plate

and then

Array -> [7] -> [2] -> [n] registration plate

I was wondering if I can call all the fields no matter the fields are filled in or not
or
somehow be able to sort them by any specification
I would like to avoid any complicated conditions since programming is not my main field.

Thank you for your help.

4

List of Units

Re: List of Units

Hello jiri.mechura !

Please find below example of all possible profile fields in unit settings.
It's not possible to get all them by some request, but you can use this list to compare with real result (which fields are completed ).
Please note the id is applied in order to creation time, for example first user set up Vehicle type, so field "vehicle_type" with id:2, then - Model, "model" with id:3 and etc. So different units can have different profiles ids, and you can sort and proceed the profile field name ("n")

pflds: {1: {id: 1, n: "vin", v: "RT45355"}, 2: {id: 2, n: "vehicle_type", v: "Truck"},…}
1: {id: 1, n: "vin", v: "RT45355"}
2: {id: 2, n: "vehicle_type", v: "Truck"}
3: {id: 3, n: "registration_plate", v: "AC45663FD"}
4: {id: 4, n: "brand", v: "BMW"}
5: {id: 5, n: "model", v: "X5"}
6: {id: 6, n: "year", v: "2015"}
7: {id: 7, n: "color", v: "White"}
8: {id: 8, n: "engine_model", v: "M240"}
9: {id: 9, n: "engine_power", v: "170"}
10: {id: 10, n: "engine_displacement", v: "2.0"}
11: {id: 11, n: "primary_fuel_type", v: "98"}
12: {id: 12, n: "cargo_type", v: "Custom"}
13: {id: 13, n: "carrying_capacity", v: "5"}
14: {id: 14, n: "width", v: "50"}
15: {id: 15, n: "height", v: "20"}
16: {id: 16, n: "depth", v: "20"}
17: {id: 17, n: "effective_capacity", v: "5"}
18: {id: 18, n: "gross_vehicle_weight", v: "15"}
19: {id: 19, n: "axles", v: "2"}
Diana Cheley
Wialon Hosting Expert
Gurtam