Skip to Content
0
Dec 08, 2022 at 08:30 AM

Search restriction applied on B2BCustomer

123 Views

Hi All,

I have a search restriction applied on B2B customer item type, if it has a user group "salesrepgroup"
Would like to understand actual use of this restriction query
(EXISTS ({{ SELECT {pk} FROM {PrincipalGroupRelation} WHERE {source}={item:pk} AND {target} IN ( ?session.branch ) }} )

OR
EXISTS (
{{ SELECT {pk} FROM { B2BCustomer as customer
JOIN PrincipalGroupRelation as unit_rel
ON {unit_rel:source} = ?session.branch
JOIN PrincipalGroupRelation as cust_rel
ON {unit_rel:target} = {cust_rel:target} }
WHERE {cust_rel:source}={item:pk} }}
)
)
AND ( {item:active} = 1 OR EXISTS ( {{ select {ug:PK} from {UserGroup as ug} where {ug:PK} IN (?session.user.groups) and {ug:uid} = 'countrymanagergroup' }} ))

Cause of this restriction, login speed is hampered