How can I filter data in an Apex Grid to show certain things for certain user groups?

一世执手 提交于 2019-12-24 11:49:18

问题


I have an ADMIN group and a USER group. My data looks something like this raw:

ID ---------- NAME --------- SECTOR
0001          John           A
0002          John           H
0024          John           A
0011          John           H
0045          John           A

The ADMIN group should only be able to see A, and the USER group should only be able to see H. How can I customize the gridview in Apex to filter it based on authorization/groups?


回答1:


Since you are using APEX built-in groups, there is a function APEX_UTIL.GET_GROUPS_USER_BELONGS_TO that can help you here. It returns a comma-separated list of the groups the user belongs to. So you could use it something like this:

select id, name, sector
from employees
where ((','||apex_util.get_groups_user_belongs_to(:app_user)||',' like '%,ADMIN,%'
      and sector = 'A')
or (','||apex_util.get_groups_user_belongs_to(:app_user)||',' like '%,USER,%'
      and sector = 'H'))


来源:https://stackoverflow.com/questions/7956835/how-can-i-filter-data-in-an-apex-grid-to-show-certain-things-for-certain-user-gr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!