1

JS API: How to get custom fields of current user

(04/10/2014 15:42:37 отредактировано sergej.shirokov)

Тема: JS API: How to get custom fields of current user

Hello! I need to obtain custom fields of current session user.

wialon.core.Session.getInstance().loadLibrary("itemCustomFields");
var user_fields = wialon.core.Session.getInstance().getCurrUser().getCustomFields();

After successful login the code above returns null. What else should I do?

Thanks!

Sergei Shirokov / GoGPS Service
Senior Software Engineer
www.gogps.eu
Skype: sergei.shirokov
2

JS API: How to get custom fields of current user

Re: JS API: How to get custom fields of current user

Hello.

To get user's custom fields first you need to call Sesssion.updateDataFlags with user id and dataFlags including Item.dataFlag.customFields flag.

Mobile Development
Gurtam
3

JS API: How to get custom fields of current user

Re: JS API: How to get custom fields of current user

I've tried as you suggested but with no success - still getCustomFields() returns null. Note, I have only problems with getting custom fields of current user. Similar code obtaining unit custom fields works OK.

Could you please post full working example?

Sergei Shirokov / GoGPS Service
Senior Software Engineer
www.gogps.eu
Skype: sergei.shirokov
4

JS API: How to get custom fields of current user

Re: JS API: How to get custom fields of current user

Hi

Parent users can save in users custom fields some secret info and user himself shouldn't be able to access it.
So current user cant access his custom fields.

5

JS API: How to get custom fields of current user

Re: JS API: How to get custom fields of current user

I thought this is the case when "mark as admin field" is checked... OK, then what is the right choice to store something in an user object so that later this user be able to read it?

Sergei Shirokov / GoGPS Service
Senior Software Engineer
www.gogps.eu
Skype: sergei.shirokov
6

JS API: How to get custom fields of current user

Re: JS API: How to get custom fields of current user

sergej.shirokov пишет:

I thought this is the case when "mark as admin field" is checked... OK, then what is the right choice to store something in an user object so that later this user be able to read it?

Try custom properties. But remember, that custom properties always sended in login response, so if your "something" is large - it can be a problem.

Another variant - wait week or two for new version of wialon fileserver. Using it you'll be able to read/write text info from/into file on the server. All these files binded to items, in your case - user.