1

JS API: Custom fields and profile fields all coming with same name

Topic: JS API: Custom fields and profile fields all coming with same name

Hello Team,

I need your urgent help. I am building  web app fora client that needs a custom report of vehicle's list report that includes the unit's custom fields(Site Name, Site ID) and some profile fields (VIN, Year, Make, Model)

But when I pull data about the units all custom fields and profile fields come with the right values but all having same name of the first set field in the system. see below;

.$$user_customFields: {
1:{id: 1, n: "Site Name", v: "HK001UG"},
2:{id: 2, n: "Site Name", v: "Hima Kasese"}
3:{id: 3, n: "Site Name", v: "MERCEDES ACTROS"}
}

.$$user_profileFields:{
1: {id: 1, n: "year", v: "550"},
2:{id: 2, n: "year", v: "ACTROS"
}

Is there anything am not doing right? below is a snippet of my code


var sess = wialon.core.Session.getInstance();

sess.loadLibrary("itemIcon");     
sess.loadLibrary("itemCustomFields"); 
sess.loadLibrary("itemProfileFields"); 
sess.loadLibrary("unitDriveRankSettings");
sess.loadLibrary("unitEvents");
sess.loadLibrary("unitTripDetector");

var flags = wialon.util.Number.or(wialon.item.Item.dataFlag.base,  wialon.item.Unit.dataFlag.lastMessage, wialon.item.Item.dataFlag.customFields, wialon.item.Item.dataFlag.adminFields, wialon.item.Item.dataFlag.customProps, wialon.item.Item.dataFlag.guid, 256, 8388608, 131072, 524288, 8192);

sess.updateDataFlags( [{type: "type", data: "avl_unit", flags: flags, mode: 0}], function (code) 
        if (code) { console.log(wialon.core.Errors.getErrorText(code)); return; } // exit if error code
        var units = sess.getItems("avl_unit");
        if (!units || !units.length){ console.log("Units not found"); return; }
     
        for (var i = 0; i< units.length; i++){ 
              var u = units[i];
              console.log(u);
       }
});

please help.

2

JS API: Custom fields and profile fields all coming with same name

Re: JS API: Custom fields and profile fields all coming with same name

All looks valid and for my user all custom fields names are various.

Are you sure, that they must be different? What names do you see in Wialon Hosting interface (actually it uses the same SDK)? What you are receiving in core/update_data_flags response?

3

JS API: Custom fields and profile fields all coming with same name

Re: JS API: Custom fields and profile fields all coming with same name

Attached is what I see in the wialon hosting dashboard.


show me a sample request url for core/update_data_flags

Post's attachments

Attachment icon custom_fields 21.34 kb, 646 downloads since 2018-06-22 

4

JS API: Custom fields and profile fields all coming with same name

Re: JS API: Custom fields and profile fields all coming with same name

But please note that thisis notonly hppening to the customfields but also the profile fields.

5

JS API: Custom fields and profile fields all coming with same name

Re: JS API: Custom fields and profile fields all coming with same name

Sorry the image is displayed below


JS API: Custom fields  and profile fields all coming with same name

6

JS API: Custom fields and profile fields all coming with same name

Re: JS API: Custom fields and profile fields all coming with same name

Oh sorry I discovered the code snippet that would change the field keys.

Consider this closed