Forum Stats

  • 3,734,280 Users
  • 2,246,936 Discussions
  • 7,857,218 Comments

Discussions

Display different buttons depending on user

User9999
User9999 Member Posts: 27 Green Ribbon

Hello all,

I recently received a request that I'm not sure how to implement in APEX.

It is about the fact that when a user logs in, he gets to see a 'different' button on an overview page.

Behind this button is a function that redirects the user to the right page.


The requirement is, however, that the name of the button should display something different depending on the status of the user.

Use Case 1: The user does not yet have a status in the process because he has not submitted anything. The button should therefore display something like: "Submit Form"

Use Case 2: Registered user has already submitted a form, button should display: "Take me to last status".

For that I have two tables:

  1. Table: holds all relevant values of the form
  2. Table: holds 'state of form', 'page' and 'ID' of tbl1

Depending on state of the form in tbl1, the corresponding row in table 2 will be updated.

So table 2 holds for example these values:

ID STATE PAGE

1 REQUESTED 14

3 APPROVED 17


I then created a function, which should set the page depending on logged in user and the entry in table 2.

create or replace function forwarding_to_page2(p_username in varchar2,p_key_value in number)

return number

is

l_user varchar2(255);

l_page number;

l_tbl1id number;


begin

l_user :=p_username;

l_tbl1id :=p_key_value;

 /*

  Get the target page depending on stored page column in table 2

 */

select 

 tbl2.page

 into l_page

from 

TABLE2 tbl2 

where exists (select tbl1.RESP1 from TABLE1 tbl1

left outer join RESPONSIBLE1 r on r.RESPID=tbl1.RESPID

LEFT OUTER JOIN USERS u on u.UUID=r.UUID where lower(u.USERNAME) =lower(l_user))

AND l_tbl1id=tbl2.ID;

return l_page;


exception

 when no_data_found then

  /*Use current registration page as default page*/ 

 return 18;


  end ;


The registered users occupy a role in table 1. These roles have a foreign key to the user table. This makes it possible to check which user is logging in and whether the logged-in user has a connection to table 1. On this basis, the function checks which page number is stored in table 2 then check and redirect user to this page.

If no data is found, then the user should be redirected to another page and the button should display something else. 

So my actual question is, how can I display different text for a user that has not submitted a form yet (so is not in table 1 and table 2) and for a user that has already submitted a form (exists in table 1 and table 2).

I would be very grateful for some suggestions:)

Tagged:

Best Answer

Answers

Sign In or Register to comment.