Monday, December 24, 2018

Multiple reports with a link




Recently one of customer has a new request in terms of making two reports only with a link so I found this solution and I would like to share it in this post. At the first I have read this post about How To Add Open Multiple Links / Windows In a Single Click .


In this sample we have two reports and when I click on a link to run in two different tabs on our browser.


Demo application : OAC



Step 1:

Creates a page for example 22 


Step 2:

Creates a process on Process after header for example Call_Print_Documents.
We have two reports [print_test1, print_test2] and calls a report when page loads.







BEGIN
    if :Request= 1 then 
        APEX_UTIL.DOWNLOAD_PRINT_DOCUMENT(
                        p_file_name => 'rep1',
                        p_content_disposition => 'inline',
                        p_application_id => :APP_ID,
                        p_report_query_name => 'print_test1',
                        p_report_layout_name => 'print_test1',
                        p_report_layout_type => 'rtf',
                        p_document_format => 'PDF'); 
    elsif :Request= 2 then 
        APEX_UTIL.DOWNLOAD_PRINT_DOCUMENT(
                        p_file_name => 'rep2',
                        p_content_disposition => 'inline',
                        p_application_id => :APP_ID,
                        p_report_query_name => 'print_test2',
                        p_report_layout_name => 'print_test2',
                        p_report_layout_type => 'rtf',
                        p_document_format => 'PDF'); 
    end if;          
END;


Step 3:

Creates a page for example 23 , in this page has a link for calling report page in order to open two new tabs.



Step 4:

Create a link on Display Item and we use below code at Post Text property.






<div>Multiple reports with a link
    
<a class="t-Button t-Button--icon t-Button--hot t-Button--iconLeft" value="reports" 
   href="f?p=&APP_ID.:22:&SESSION.:1:NO:" 
   onclick="window.open(&quot;f?p=&APP_ID.:22:&SESSION.:2:NO:&quot;);" 
   target="_blank" rel="noopener"><span class="t-Icon fa fa-print" aria-hidden="true"></span>
</a>
</div>



Finally, when I click on a link as result the first tab will open but second tab will not open because the browser block this link (window.open) and we have to according below images to choose "Always allow ..." after that when clicks again on the link we can see two new tabs, also you could use this property (rel="opener") in your link. In addition to recommend to read this post about rel=noopener





I hope this helps.






No comments :

Post a Comment