Grid Filter

Posted by stephen.vanrooyen on 02-Feb-2017 01:20

Hi Guys,
 
Is there a way to filter records in a grid, similarly to how you would filter a View?
 
I have a grid component on a Portal page and would like to filter the records to only show records for the specific Portal user.
 
Also when creating new records, they should only be able to create records for themselves.
If I include the Portal User field in the Grid, they can then change the value.
If I make it read only, how do I assign the value for new records?
 
Regards,
http://www.aigs.co.za/templates/email_signatures/2016/stephen_van_rooyen.png
 

Posted by mpiscoso@gmail.com on 03-Feb-2017 07:24

I see, i think what you need to do is to remove the View permission of the portal user on the object in question. Then you need to enable the view permission of the relationship between the portal user and the object. You should see this both in the permission settings.

For the trigger, i dont think that there is currently a better way to do this.

Hope this helps.

All Replies

Posted by mpiscoso@gmail.com on 03-Feb-2017 03:55

In grid controls you should be able to set a specific view to use for each lookup field in the grid.

For me, to be able to do "I have a grid component on a Portal page and would like to filter the records to only show records for the specific Portal user." I would create new views specifically for your portal (no permissions to anyone except portal users) and set a filter Portal User object == CURR_VISIT per view.

This way all records that are seen in the lookup should belong to the currently logged in portal user.

As for record creation where you need them to be able to create records for themselves, don't include the Portal User field in the grid due to the obvious drawbacks and problems. What I would do in this case is to create a trigger on your Grid's object where during after create if a record is being created from the portal (rbv_api.isPortal() == true) I would automatically assign the Portal User relationship with the currently logged in portal visitor {!#CURR_VISIT.id}

I'm not 100% sure about the token's validity but the description should give you an idea on its implementation.

Hope this helps.

Posted by stephen.vanrooyen on 03-Feb-2017 06:26

Hi,
 
Thanks for the response, but I think my question might not have been clear.
Grid Filter:
I’m referring to the actual records (rows) displayed the Grid, not the lookup fields.
A view component allows you to filter the records displayed, as per the screenshot below.
I would like to do the same or similar for a Grid component.
Without this filter, a Portal user can see records belonging to all other portal users.
 
I created an After Create trigger to assign the value to the current Portal User, I just figured there might be a better way to achieve this.
 
Regards,
http://www.aigs.co.za/templates/email_signatures/2016/stephen_van_rooyen.png
 
 

Posted by mpiscoso@gmail.com on 03-Feb-2017 07:24

I see, i think what you need to do is to remove the View permission of the portal user on the object in question. Then you need to enable the view permission of the relationship between the portal user and the object. You should see this both in the permission settings.

For the trigger, i dont think that there is currently a better way to do this.

Hope this helps.

Posted by murali on 03-Feb-2017 07:58

 
Unlike Apps,  Portals  do not have full-fledged Roles ( as of now ).  And like you said, that allows Portal Users to see all records.
 
Lets say  ‘Portal User’ of  type ‘Subscriber’  should only be able to  view,update,delete his own ‘My_Subscription’
The way to restrict this is :
1) For ‘Portal User’ role, disable access to  View , Edit, Delete   Object,  lets say,   ‘My_Subscription’  ( In Roles Page)
 
2)  Create a relationship between  ‘Subscriber’ and ‘My_Subscription’
 
3) In the Object page of  ‘My_Subscription’, Permissions section :   Allow  ‘related Subscriber’  to   view, edit & delete
 
This will make sure that  a ‘Subscriber’  can only  deal with  his own ‘My_Subscription’ objects.
 
 

Posted by stephen.vanrooyen on 06-Feb-2017 00:15

Hi Guys,
 
Thanks for the feedback,
 
As suggested I removed the permissions from Portal User and instead added the permissions to the relationship between the Object and Portal User.
This was exactly what I was after.
 
Thanks again for the assist, much appreciated.
 
Regards,
http://www.aigs.co.za/templates/email_signatures/2016/stephen_van_rooyen.png
 

This thread is closed