Introduction
In one of the previous article, we have seen how to create a static password protected PDF output Report in Oracle HCM Cloud Application. In some cases like EmployeePayslip, Annual Reward Letter or CompensationLetter there is a need to have a file, which should have a dynamic password. One can have a dynamic password by creating two specific attributes namely xdo-pdf-security and xdo-pdf-open-password respectively in the RTF file of the BI Publisher Report.
In order to have a dynamic password we need to ensure that we have a XML data element present which could be mapped to the xdo-pdf-open-password field so that when the value stored in that XML element is passed then only the PDF file opens up.
Let us now see how can we create such a Report.
We would create a Data Model based on a SQL query. The SQL query used for this example is below:
SQL Query Used |
SELECT FT.* FROM ( SELECT T1.*, T1.NID||T1.DOB password FROM (SELECT 1 as EmployeeNumber, 'Alfred Thomas' as EmployeeName, 10000 as AnnualSalaryinUSD, 10 as BonusPercentage, 'QY7865W' NID, 10151972 DOB FROM dual ) T1 UNION SELECT T2.*, T2.NID||T2.DOB password FROM (SELECT 2 as EmployeeNumber, 'Barack Alfonso' as EmployeeName, 20000 as AnnualSalaryinUSD, 20 as BonusPercentage, 'SW864E' NID, 11171995 DOB FROM dual ) T2 UNION SELECT T3.*, T3.NID||T3.DOB password FROM (SELECT 3 as EmployeeNumber, 'Chris Matthew' as EmployeeName, 30000 as AnnualSalaryinUSD, 30 as BonusPercentage, 'GT603J' NID, 12241987 DOB FROM dual ) T3 UNION SELECT T4.*, T4.NID||T4.DOB password FROM (SELECT 4 as EmployeeNumber, 'Derek Laker' as EmployeeName, 40000 as AnnualSalaryinUSD, 40 as BonusPercentage, 'JK273T' NID, 10291998 DOB FROM dual ) T4 ) FT WHERE FT.EmployeeNumber = :p_employeenumber |
We would now need to use the above SQL query and create a Data Model out of it (CompensationDetailDataModel is the name given for the Data Model used in this example) and when view the XML Data it appears as below:
We have passed the Employee Number value as 2 and could see that there is a Data Attribute named Password. The attribute value stored in this data element would be the password required to open the PDF Output generated from the Report.
Creating RTF File
In order to have a PDF output from BI Publisher report we need a RTF File. For this example we would have a RTF file which would look something like below:
We would have to create two custom properties for the RTF template . Details of the same are below:
Name |
Type |
Value |
xdo-pdf-security |
Text |
true |
xdo-pdf-open-password |
Text |
{/DATA_DS/G_1/PASSWORD} |
These details when entered into the properties section will appear on the screen.
We can now upload the RTF to the Report layout and try running the Report and when we do that we encounter the following screen:
The PDF file looks for a password. We have mapped the password of the output file to the PASSWORD XML Element. Check the XML file which was generated when we ran the Data Model.
We could see that there is a Data Element named PASSWORD and it holds the value SW864E11171995. This is basically a concatenation of the Employee’s NID (National Identification Number) followed by his/her DOB (Date of Birth) in MMDDYYYY format.
Now we would pass the same value and try to open the PDF file.
Now once we click on OK we would be able to see the PDF Output
Inference
This is how we can have a dynamic password for a PDF output file generated using BI Publisher. For this example we used a combination of Employee’s National Identifier along with his/her DOB to create the dynamic password but one can choose any specific logic to achieve the same. The only important point being defining the two properties xdo-pdf-security and xdo-pdf-open-password in the RTF File used for the same.
I hope this was a good read and would help you guys to generate secure output files using BI Publisher.
Thank you all for your time and have a great day ahead!