FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
2 weeks ago
I am going to assign the user group to some virtual variable. I've found this function in Visuals
getUserData(key [, lookupIn])
and trying to extract the group from current logined user:
const im = shmi.requires("visuals.session.UserManager");
let a = im.getUserData('group');
console.log(a);
But, I've got null as a result. What I am doing wrong, maybe someone has code example?
2 weeks ago - last edited 2 weeks ago
I am very confused what you are trying to do here. Why do you have a user named group?😂
The function getUserData() searches the userData and groupData properties of the current user object. As you can see here, these objects are empty on my test user in the group testGroup after initial creation. It's not clear to me if you can modify these through the WebIQ Designer somehow. The User Data fields in the User Manager don't seem to affect these properties.
If I first call setUserData() and add some properties to this object, getUserData() will return them as expected.
Sample code is below
const um = shmi.requires("visuals.session.UserManager");
um.setUserData({
"hello": "world",
"deleteme": null,
"test" :1234
});
let a = um.getUserData('hello');
let b = um.getUserData('test');
console.log(a);
console.log(b);