fetch method on report, can not retrieve multiple groups for one field

Hello world

I’m stuck in a report, here is what I’m supposed to do. I have to create a report that will print a userId, UserName, GroupName and UserGroupNames. The trick is with the GroupName and UsrGoupName.

GroupName: I’m requested to print only the users that are managers. {solved}

UserGroupName: These groups are groups where the manager also has permission to/belong to e.g DocHand and Admin. So when the report is printed there must be these groups as well.

My solution only retrieves one group amongst all the groups that the manager is also connected to and it it retrieves one for all managers that are retrieved.

Here is my fetch method:

public boolean fetch()
{
boolean ret;
QueryRun qr;
QueryBuildDataSource qbs;
UserGroupList userGroupList;
UserGroupInfo userGroupInfo;
UserInfo userInfo;
qr = new QueryRun(element.query());

// qbs = qr.query().dataSourceTable(tablenum(UserGroupList));
ret = super();
while (qr.next())
{
userGroupList = qr.get(tablenum(UserGroupList));
name = (select name from userInfo where userInfo.id == userGroupList.userId).name;
element.send(userGroupList);
}
// return ret;
return true;

}

Here is how the report looks like: