Using RPCs (Remote Procedure Calls)

There are three different ways of using RPCs within a template:

  • On download: these are thought to download data from an external source (depending or not on some parameters) whenever the document is loaded in the end user browser.
  • Dropdown menus: to fill a custom dropdown menu that may also depend on some parameters.
  • Automatically triggered: these RPCs are triggered by other RPCs and take ass parameter the value of the dropdown than trigger them.

Notice that all used RPCs should have been previously defined within Docxpresso, see defining RPCs within Docxpresso.

We now pass to explain their use in detail.

Loading external data on download

You may wish to download data from an external server on document download (this can also be done at the server level with the requestDataURI parameter). In order to do so click on the gear button on the top menu of the template processing interface and afterwards press on "Remote Procedure Calls".

A pop up window will show up with a dropdown that will list all the predefined RPCs for the onLoad event. If you choose one of those listed RPCs it will be automatically called when the template is loaded in the end user browser.

If the chosen RPC depends on any parameter or parameters, they will be taken in the following order:

  1. The GET or POST data.
  2. If not given in the HTTP request by GET or POST, the user will be prompted to provide them through a standard (although customizable) browser dialog window.

IMPORTANT: Notice that that called will only take effect whenever there is no data loaded from the server to avoid potential conflicts.

Dropdown menus

Whenever clicking on a variable in the template processing interface a pop up will show up where you could choose the variable type. One of the options is "remote procedure call" whenever this type is chosen an additional dropdown menu with a list of available RPCs will be shown. By selecting one of them the dropdown will be filled with the data provided by such RPC.

As before if the RPC depends on any parameter it will get it from the GET or POST data and if not provided will prompt the user to introduce the data via a browser dialog interface.

Triggered RPCs

The RPCs associated with a dropdown may have an additional RPC that may be triggered whenever an option of the dropdown menu is selected.

Imagine, for example, a dropdown of products from a catalog. Whenever a certain product from the catalog is selected we may like to retrieve its price or any other associated info.

Notice that which RPC is triggered may only be defined within the RPC edition interface and cannot be changed for a specific template.