A document block shows an embedded PDF document.
It may also include a drop-down list of alternative documents to view. If multiple documents are available the first item is shown by default.
The block has two properties:
Property | Example Usage | Description |
No items text |
It won't be long until your first payday :-) | The text to show when no items are available |
REST data source | assignments/{INSTANCE_PK1_VALUE}/payslips | See Setting the REST data source. |
Setting the REST data source
The REST data source is a REST API endpoint that returns the list of documents in the required shape.
You can normally use one of the pre-existing utility REST APIs, such as the function-data* APIs. If these APIs do not suit your requirements you may need to write your own REST API.
You can use the special tokens {INSTANCE_PK1_VALUE} to {INSTANCE_PK5_VALUE} in the REST data source. and you can also use any of the page keys wrapped in curly braces, for example, {PERSON_ID}. These will be replaced by the value from the block object's primary key 1 to 5 or from the page key respectively. For example, if the REST data source is function-data/XXAS_DT_ABSENCE_LIST/by-person/{INSTANCE_PK1_VALUE} then {INSTANCE_PK1_VALUE} would be swapped out for the Primary Key 1 value on the block's object – in this case, a Person Id.
REST API shape
The REST API should return an array of items that contain the following properties:
Property | Description |
documentType | Set this to 'pdf' |
title | The title of the document |
url | The URL to the PDF document. This should be an https URL, otherwise, native apps and desktop browsers may block the connection |
When using the utility APIs, the database object linked to the Application Function can simply be a view that selects a list of documents, as illustrated in this example:
SELECT 'pdf' "documentType"
,f.file_title "title"
,f.file_url "url"
FROM my_files_table f;
If you're writing your own REST API, the API should return XML in this format:
<?xml version="1.0" encoding="UTF-8"?> <data xmlns:json="http://json.org/" json:force-array="true"> <item> <documentType>pdf</documentType> <title>31 Jan 2008 - 119 - Check 1</title> <url>https://myhost.ebsdomain.com/OA_HTML/applaud/api/assignments/259/payslips/8809896/XXAS_PAYSLIP_US_TEMPLATE/XXAS_EMP_VIEW_PAYSLIPS?_accept=application/pdf</url> </item> <item> <documentType>pdf</documentType> <title>15 Jan 2008 - 119 - Check 1</title> <url>
https://myhost.ebsdomain.com/OA_HTML/applaud/api/assignments/259/payslips/8798735/XXAS_PAYSLIP_US_TEMPLATE/XXAS_EMP_VIEW_PAYSLIPS?_accept=application/pdf</url> </item> <item> <documentType>pdf</documentType> <title>31 Dec 2007 - 119 - Check 1</title> <url>
https://myhost.ebsdomain.com/OA_HTML/applaud/api/assignments/259/payslips/8788976/XXAS_PAYSLIP_US_TEMPLATE/XXAS_EMP_VIEW_PAYSLIPS?_accept=application/pdf</url> </item> <item> <documentType>pdf</documentType> <title>15 Dec 2007 - 119 - Check 1</title> <url>
https://myhost.ebsdomain.com/OA_HTML/applaud/api/assignments/259/payslips/8779348/XXAS_PAYSLIP_US_TEMPLATE/XXAS_EMP_VIEW_PAYSLIPS?_accept=application/pdf</url> </item> </data>
Using XML Publisher for dynamically-generated documents
If you wish to use a dynamically-generated document rather than a static PDF you will need to write your own REST API. Please see REST APIs.
When you have a REST API available you can then generate a URL to that REST API. The following example creates a URL to a REST API with the path custom/w8-ben/{personId}:
SELECT xxas_com_rest_util_pkg.uri_from_path('custom/w8-ben/' || papf.person_id || '?_accept=application/pdf') "url"
FROM per_all_people_f papf;