Add button to a viewThe first thing we need to do is add a button to a view, to be able to create an output document. This action is already explained in one of our previous blogs.
Add buttons to view
The output could be a document created by an Adobe Form. Unfortunately for you we will not describe how to create forms and how to generate output, after clicking the button in the CRM Webclient. Plenty of blogs could be written on that topic. For now we assume that a PDF document is created, after clicking the button, and that it can be viewed by calling the correct URL.
Store link to output documentOnce the output is created we need to store it’s location. For that purpose, in the controller class of the view, we create an attribute to save the URL.
This attribute is filled in the event handler of the button.
Open the URL
IF controller->gv_quotation_url IS NOT INITIAL .
window.open ("<%= controller->gv_quotation_url %>","<%= sy-uzeit %>");
clear controller-> gv_quotation_url.
Once the button is clicked, the action is performed and the page is refreshed, so the views .htm page is called. Here we check if a URL is stored in the controller class. If so, we open a window and view the document. Finally we clear the controller’s attribute again, to avoid calling the URL each time the page is displayed. You might notice the addition “sy-uzeit” within the “window.open” statement. This is to make sure that the window we open is unique. Otherwise calling the same URL will not open a new window again.