Topic: JS API: get and set customProps
i want set custom props for user and after log in get this props and use that values for user interface. please show me example how to use customProps // GET AND SET.
thanks...
i want set custom props for user and after log in get this props and use that values for user interface. please show me example how to use customProps // GET AND SET.
thanks...
//Get props
console.log(user.getName(),user.getCustomProps());
//Set props
var props = [{name: "John", value: "Doe"}, {name: "Foo", value: "Bar"}];
wialon.core.Remote.getInstance().startBatch();
for(var i=0;i <props.length; i++)
user.updateCustomProperty(props[i].name, props[i].value);//Update custom property, require ACL bit wialon.item.Item.accessFlag.editOther over item
wialon.core.Remote.getInstance().finishBatch(function() {
console.log(user.getName(),user.getCustomProps());
});
thanks zuve for answer but how to define user?
You can get user in 3 ways:
1) by id
var user = wialon.core.Session.getInstance().getItem(id);
console.log(user);
2) by name
var spec = {itemsType: "user", propName: "sys_name", propValueMask: "name", sortType: ""};
wialon.core.Session.getInstance().searchItems(spec, 2, wialon.item.Item.dataFlag.base, 0, 0, qx.lang.Function.bind(function(code, result) {
if (code || !result || typeof result.items == "undefined" || !result.items.length)
return;
console.log(result.items[0]);
}, this));
3) get current user
var user = wialon.core.Session.getInstance().getCurrUser();
console.log(user);
note for 1) and 2): you can only get those users that you can access according access rights
Well in your other post you tell me about reading SDK carefully... OK i was try but i think SDK have very bad logic...
for example i want learn how to use getCustomProps() i searching into SDK.... aaand its Results :
Please tell me how to use This SDK Properly.
Добавлено спустя 6 минут 9 секунд:
well zuve thats answer.... thanks again. but look bro into SDK this function getCustomProps(); is Posted into Wialon.item.Item but this Wialon.item.Item Not applicable at this moment... and into SDK is not examples like your post. therefore i post here for help ...
You can't write like this: wialon.item.Item.getCustomProps() because THIS METHOD ISN"T STATIC
yes you know about that but when developer begin learning your SDK he couldn’t understand about that...
in API docs all members of class are grupped by their types. and getCustomProps situated in METHODS section