minimalistic
minimalistic

Reputation: 21

Create a Report in SAP Hybris to Fetch Employees based on a User Group

I need help for creating a report in SAP Hybris which essentially would be used for fetching out the names of "Employees" not "Customers" based on the "User Group" they're assigned. For example : X employee has usergroup : "admingroup". Like that I would need all the Employees with the respective usergroups. Could anyone please help me with a flexisearch query for the same to start with ? I would really appreciate that ! Thank you

I am still new to SAP Hybris and I have seen a lot of other reports but wanted to try this out.

Upvotes: 2

Views: 876

Answers (2)

Raushan Kumar
Raushan Kumar

Reputation: 1248

for this report it require join with PrincipalGroupRelation as there is no direct relation with usergroup and employee.

select {user_group:uid},{user_group:locname[en]},{emp.uid},{emp.name} from {Employee as emp JOIN PrincipalGroupRelation as group_rel ON
{group_rel:source}={emp:pk} JOIN UserGroup as user_group ON {user_group:pk}={group_rel:target} } where {user_group.uid}='customersupportagentgroup'

Upvotes: 0

Felix Schildmann
Felix Schildmann

Reputation: 683

You can use the string_agg()-method to list up the user groups, it's mentioned here: How to concatenate multiple rows in flexibleSearch query in Hybris

If the method doesn't work you can try to replace it with group_concat.

You also need to join the Employee with the PrincipalGroup. You can access the employee's user groups with the attribute groups:

SELECT
{e:displayName},
string_agg({g:locName}, ', ') AS groupNames
FROM {Employee AS e}
JOIN {Employee.groups AS g} ON {g:pk} = {e:pk}
GROUP BY {e:pk}, {e:displayName}

Upvotes: 0

Related Questions