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.