Reputation: 75
I am building an APEX 5 Application for a school. There is a page called "Course Information" and it includes several Classic Reports with information such as the class roster and testing schedule. I want to include a report with grades but I only want this region to be viewable by the teacher of the course. If I can get a hidden item on the page to be filled with the username of the teacher, can I build an authorization scheme that checks APP_USER against this item and only show the region if they match?
How would I accomplish this?
Upvotes: 0
Views: 750
Reputation: 60262
I would go about this slightly differently, and wouldn't use an Authorization Scheme for this particular requirement.
Base the report on a view which has the teacher's username as one of the columns. Put a where clause in the report SQL, e.g. select col1, col2, col3 from the_view where teacher_username = :APP_USER
.
Put a Condition on the region using Rows returned based on something like select 1 from the_view where teacher_username = :APP_USER
.
This way, the report region will only be rendered if the user is allowed to view the records in it.
Upvotes: 2
Reputation: 142713
The simplest option is to use server side condition, a function that returns Boolean, for that region. Just put
return :APP_USER = 'YOUR_TEACHER';
in there. Region will render only for your teacher. Of course, 'YOUR_TEACHER' should be substituted with his real username.
Upvotes: 1