1

JS API: getting account name and account id

(20/10/2012 14:55:05 отредактировано unitedsecurity)

Тема: JS API: getting account name and account id

hello developers we need your help smile please show me example how get account name and account id from db with js API. i need ID for searchItems()... we are new in development and its not easy for us. thanks
United Security

Великий и ужасный Гиоргий Каладзе
2

JS API: getting account name and account id

Re: JS API: getting account name and account id

You can get all accounts in such way:

wialon.core.Session.getInstance().loadLibrary("resourceAccounts");
var searchSpec = {
    itemsType: "avl_resource",  // type of search item
    propName: "sys_name",  // field of search item
    propValueMask: "*", // value mask for field
    sortType: "sys_name"
};
// flags for accessing information about account
var dataFlags = wialon.item.Item.dataFlag.base|wialon.item.Item.dataFlag.billingProps;           
wialon.core.Session.getInstance().searchItems(searchSpec, true, dataFlags, 0, 0, function(code, data) {               
    if (!code) {       
        for (var i = 0; i < data.items.length; i++)
            if(data.items[i].getAccountId() == data.items[i].getId()) // if resource is account
                alert(items[i].getName());
    }           
});

Development Department
Gurtam