Cheking if a user is in a specific group

Hi,

Couldn’t find this mentioned anywhere in the forum… probably too easy :wink:

I want to make a method that checks if the current user is in a specific group.

for example:

function checkGroup(GroupName){
if current user is in GroupName, return true;
}

how would I do that?

THanks,

Andrew

While the Servoy dev-team 8) does not add a new function… this one may work for you:

var group_id   = security.getGroupId(arguments[0]) ; // the id of the group name passed as parameter
var user_groups = security.getUserGroups(); // all the groups associated to the current user
for ( var i = 1 ; i <= user_groups.getMaxRowIndex() ; i++ )
{
	if (group_id  == user_groups.getValue(i,1)) return true;
}
return false;

just call it passing a text var containing the group name to check