Ui Builder script get the user group

Dolev Peretz
Tera Contributor

hi

i work on ui builder and i need to check if the current user is part of specific group how i can get the group of my user in ui builder script? Screenshot 2024-07-21 160208.png

1 REPLY 1

Akash4
Kilo Sage
Kilo Sage

Hello Dolev,

You can start with the following script and modify according to record names and your requirement:

function evaluateProperty({api, helpers}) {
        const userID = api.user.userID;
        const grpCheck = await fetch(`/api/<your namespace>/<group_check_page>?sys_id=${userID}`); 
 //if not sys_user_group, try with other tables partaining to your UI Builder pages
        const grpData = await grpCheck.json(); //data returns JSON with isMember key-value pair
        if (grpData.isMember) {
            return 'User is available or member of group';
        }
}

Hope this helps!
Regards, Akash
_____________________________________________________________________________
Please mark it as helpful👍 or Accept Solution✔️ based on the response to your query.

Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.