46
Views
6
Comments
Solved
Regex for the aggregate Filter
Question

Hi,
            I have set of Roles in my UserProfile Application. I have spilt the role and stored in a Client Variable as GroupName. For example, if role is TRS_Admin or ER_Manager their GroupName would be GroupName = TRS or  GroupName = ER. 
So I need to filter all the users who has the Roles that starts with the Client.GroupName .


If I give "like" operation it fetches all the users with roles that contains "ER", even if it doesn't start with ER, it shows from all the Application users that has role containing ER.

How can I specifically fetch the User that that starts with the Client.Group? and Also is it possible to only the roles in my UserProfile Application ?

2023-04-16 15-25-31
Krishnanand Pathak
Solution

Hi Annie,

You can use below filter as also suggested by Wasim:
Role.Name like Client.GroupName + "%" 

You can also check how Like operator works using below link
https://www.w3schools.com/sql/sql_like.asp

Regards
Krishnanand Pathak

2021-10-17 12-36-16
Amreen Shaikh

Hi Annie,

You can use :

Substr(Client.GroupName, 0,3) ,


Regards,

Amreen

2023-05-23 04-55-55
Wasimkhan Syed Abuthahir

Hi,

You can apply the filter like Role.Name like Client.GroupName+"%"

this will fetch you the group starts with Client.Group


Regards,

Wasimkhan S 

2023-04-16 15-25-31
Krishnanand Pathak
Solution

Hi Annie,

You can use below filter as also suggested by Wasim:
Role.Name like Client.GroupName + "%" 

You can also check how Like operator works using below link
https://www.w3schools.com/sql/sql_like.asp

Regards
Krishnanand Pathak

2021-11-29 15-03-17
Mike Nisbet

Hi Annie,

The answers suggested by Krishnanand and Wasimkhan are perfect if you want to continue using Client variable and 'like' operator in your filter.

But to answer your second question: "is it possible to only the roles in my UserProfile Application?" - you can do this.

In your aggregate you can use the function for Checking Roles to return a new attribute value giving a boolean whether each user has that specified role.
This can then be used in your filter criteria.

(example above I just created the Roles, I do not have any users assigned :D )

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Mike,

That's a bad and nonsensical answer. You cannot use any OutSystems Function (with a few exceptions) in an Aggregate if it's result isn't static, that is, a Function that's used in an Aggregate cannot have an input that's an Entity Attribute. The reason for that is clear: an Aggregate is executed in the database, and the database cannot execute the Function.

In your example, what happens is that all rows of the query return the same value for CheckMyRoleRole(), as the function is evaluated before the Aggregate runs (using the currently logged in user as input).

2021-11-29 15-03-17
Mike Nisbet

Thank you for the pointers Kilian.
Happy to learn.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.