This discussion is archived
10 Replies Latest reply: Feb 20, 2013 7:58 AM by kingjames RSS

Redirecting to different pages based on value from table linked from report

kingjames Newbie
Currently Being Moderated
Hi,

I wanted to navigate to different pages from a report link based on a value from the table on which the report is built. I was able to link to particular page without any problem.

But, I wanted to link to different pages based on value in the table. Please let me know how can I do this?

Thanks,
  • 1. Re: Redirecting to different pages based on value from table linked from report
    matthew_morris Expert
    Currently Being Moderated
    In the field for the branching or redirecting page, you can put in page items. I use this for redirecting my pages back to the page that called them. In the branching section I have something like *&P2_SOURCE_PAGE.* instead of a hard-coded page number. One possible caveat depending on how your pages are being generated, Using this method, Apex grabs the P2_SOURCE_PAGE value at the time the page is rendered, not at the time it is submitted. If the value changes after the page has been rendered, Apex will redirect to the original value.
  • 2. Re: Redirecting to different pages based on value from table linked from report
    kingjames Newbie
    Currently Being Moderated
    I have query the table to know which page I have to redirect.. how can I do that from your answer
  • 3. Re: Redirecting to different pages based on value from table linked from report
    fac586 Guru
    Currently Being Moderated
    kaminey wrote:
    Hi,

    I wanted to navigate to different pages from a report link based on a value from the table on which the report is built. I was able to link to particular page without any problem.

    But, I wanted to link to different pages based on value in the table. Please let me know how can I do this?
    APEX version?

    Is this a standard or interactive report?

    How does the value from the table determine the target page used in the link? Is it a page number? Or the result of some computation or process?
     
    -----


    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:

    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)

    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
  • 4. Re: Redirecting to different pages based on value from table linked from report
    kingjames Newbie
    Currently Being Moderated
    I'm using Apex 4.2 and my report is a classic report.

    If I click on empID in a classic report now it redirects to page 1. Now what I want to do is, If I click on empID if his role is MANAGER it should be redirect to page 2 and fill the form on page with employee details. if the employee's role is ANALYST it should be redirect to page 3 and fill the form on page with his details
  • 5. Re: Redirecting to different pages based on value from table linked from report
    matthew_morris Expert
    Currently Being Moderated
    If I click on empID if his role is MANAGER it should be redirect to page 2 and fill the form on page with employee details.
    if the employee's role is ANALYST it should be redirect to page 3 and fill the form on page with his details
    OK. In that case, I'd likely actually build the redirect button as part of the report columns. Create a function similar to the below (not compiled/tested/etc -- likely to contain syntax errors if nothing else). Select the function as one of the columns ot the report and pass it the employee ID and the role. It will return (currently) the EMP_ID as a hyperlink. You can also make it return a button image if you prefer. (I tried to put more in the href than just apex_page_ref initially but I forgot the forum edits that out...)
    FUNCTION emp_report_redirect(p_emp_id     NUMBER,
                                 p_emp_type   VARCHAR2)
    RETURN VARCHAR2
    AS
    BEGIN
      CASE p_emp_type
        WHEN 'EMPLOYEE' THEN
          RETURN '<a href="apex_page_ref">' ||   
                   p_emp_id || '" title="Jump to Employee page">' || p_emp_id || '</a>';
        WHEN 'EMPLOYEE' THEN
          RETURN '<a href="apex_page_ref">' ||   
                   p_emp_id || '" title="Jump to Manager page">' || p_emp_id || '</a>';
        ELSE
          RETURN '<a href="apex_page_ref">' ||   
                   p_emp_id || '" title="Jump to ANalyst page">' || p_emp_id || '</a>';
      END CASE;
    END emp_report_redirect;
  • 6. Re: Redirecting to different pages based on value from table linked from report
    fac586 Guru
    Currently Being Moderated
    kaminey wrote:
    I'm using Apex 4.2 and my report is a classic report.

    If I click on empID in a classic report now it redirects to page 1. Now what I want to do is, If I click on empID if his role is MANAGER it should be redirect to page 2 and fill the form on page with employee details. if the employee's role is ANALYST it should be redirect to page 3 and fill the form on page with his details
    And if the role is neither MANAGER nor ANALYST? Does it still go to page 1?
  • 7. Re: Redirecting to different pages based on value from table linked from report
    kingjames Newbie
    Currently Being Moderated
    It will definitely be either one of them
  • 8. Re: Redirecting to different pages based on value from table linked from report
    kingjames Newbie
    Currently Being Moderated
    Thanks for your reply morris... But, How to build the redirect button as part of the report columns and pass empid and roles?
  • 9. Re: Redirecting to different pages based on value from table linked from report
    fac586 Guru
    Currently Being Moderated
    kaminey wrote:
    I'm using Apex 4.2 and my report is a classic report.

    If I click on empID in a classic report now it redirects to page 1. Now what I want to do is, If I click on empID if his role is MANAGER it should be redirect to page 2 and fill the form on page with employee details. if the employee's role is ANALYST it should be redirect to page 3 and fill the form on page with his details
    This approach makes maximal use of standard APEX features and minimises additional coding.

    1. If it's not already included as a displayed value, include the role column yielding the MANAGER/ANALYST value as a hidden column in the report.

    2. Create the column link on the EmpID column, with the link target set to the same page as the report, and Request set to the role column value (e.g. <tt>#ROLE#</tt>).

    3. On the report page, create an On Load: Before branch to page 2, with a Request = Expression 1 condition with Expression 1 set to <tt>MANAGER</tt>.

    4. On the report page, create an On Load: Before branch to page 3, with a Request = Expression 1 condition with Expression 1 set to <tt>ANALYST</tt>.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points