cancel
Showing results for 
Search instead for 
Did you mean: 

How to assign user group to the variable?

How to assign user group to the variable?

Hemingway
Established Member

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?

1 REPLY 1

Sgilk
Contributor

@Hemingway ,

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.

Sgilk_0-1713298811349.png

If I first call setUserData() and add some properties to this object, getUserData() will return them as expected.

Sgilk_1-1713299094568.png

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);

 

 

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist