24
Views
16
Comments
Solved
How to show only data which have the name of user
Question

Hello guys, i have this table and i need the table show only the registers of the user which is logged. How i do?


Rank: #171
Solution

Francisco, you are almost there, don't give up!

The right way to do the last part... for an admin to see every ticket is to change the filter in your query.

Normally you will want not just one User to be the admin, you will want to define an admin role!

So everyone that has this role will be able to see all the Tickets. 

For this you will not need a SiteProperty, what you have to do is check if either the user has the admin role or if he is the User Assigned to the Ticket.

For that, do the following:

1 - First create a new role:

And then:


2 - After that lets change the filter of your aggregate in this way:


CheckTicketAdminRole(UserId:) = True or YourTableName.UserId = GetUserId()


This way, every user that has the role TicketAdmin will see every ticket in the table, while the ones that don't have this role will see only the tickets that are assigned to them...


After creating the role, make sure to Grant it to the user you want through /Users app.


To access it just go to the link of your environment and add /Users <yourlink>.com/Users for example.

More details about granting roles you can see here.


Users app is a native functionality of OutSystems, where you can manage your users permissions.


Additionally, every role you create in Service Studio, will have a function created automatically named Check'RoleName'Role() that you can use in your Database query to filter your users like we did in the sample! They are under the role, just expand it in the roles folder in expression editor like the sample.


Hope it helps :)

Cheers and Regards,

RR :)

Rank: #172

Hi Francisco,

Please, create a diagram whith your tables, tables that you use in this screen, incluse [user],

for we understand better how is your relationship accross tables


Regards.

Rank: #373

Hi, friend!

In the filter session of the table, set the ...MYENTITY.UserId of the current table = the method getUser().

Rank: #373

You table don't have relationship with User entity. 

Add an UserId attribute to this table and it will be solved.

Anyway, there's no relationship, so te records in SuportTicket entity will show no user.

You need to fix how it's been recorded to use as you wish in the first place.

Rank: #172

Francisco,

You need add a new field in your table:

like this:


When you create news SuporteTicket, set the UserId with getUserId():


So, to show only SuporteTicket by user, in your aggregate filter :

SuporteTicket.UserID = GetUSerID() .. as Lenon commented.

Regards.

Rank: #427

Hi,

The "SupportTicket" entity must have a new attribute UserId, which is a foreign to key to "User" system entity. Then to show only logged user records you have to use the "GetUserId" built-in function.

SupportTicket.UserId = GetUserId()

Rank: #681

Sorry guys, i try but i seeing that´s it´s must be possible, it don´t appears when the user is login. Thanks for try help me 

Hello Francisco,


You're not going to get any support ticket records from above filter. 

Reason : Administrator is not creating any ticket so SuporteTicket.UserId does not contain Admin userId.

Solution: I can see you have 2 blocks to fetch suporteTicket 

If you are using these different blocks to fetch suporteTicket in different screen. Then just remove filter from GetSuporteTicketById aggregate under SuporteTicketAdministrator block so that administrator can get all the records. Maintain that filter only in block which is for other user.


Let me know if it helps.

Regards,

Sanjay 

Rank: #171
Solution

Francisco, you are almost there, don't give up!

The right way to do the last part... for an admin to see every ticket is to change the filter in your query.

Normally you will want not just one User to be the admin, you will want to define an admin role!

So everyone that has this role will be able to see all the Tickets. 

For this you will not need a SiteProperty, what you have to do is check if either the user has the admin role or if he is the User Assigned to the Ticket.

For that, do the following:

1 - First create a new role:

And then:


2 - After that lets change the filter of your aggregate in this way:


CheckTicketAdminRole(UserId:) = True or YourTableName.UserId = GetUserId()


This way, every user that has the role TicketAdmin will see every ticket in the table, while the ones that don't have this role will see only the tickets that are assigned to them...


After creating the role, make sure to Grant it to the user you want through /Users app.


To access it just go to the link of your environment and add /Users <yourlink>.com/Users for example.

More details about granting roles you can see here.


Users app is a native functionality of OutSystems, where you can manage your users permissions.


Additionally, every role you create in Service Studio, will have a function created automatically named Check'RoleName'Role() that you can use in your Database query to filter your users like we did in the sample! They are under the role, just expand it in the roles folder in expression editor like the sample.


Hope it helps :)

Cheers and Regards,

RR :)

Rank: #681

Thanks for all help guys