QR CODE GENERATION IN PEGA
Updated: Feb 26, 2020
What is a QR Code?
QR Code is a two-dimensional bar-code that is readable by smartphones or any scanners. It allows to encode over 4000 characters in a two dimensional bar-code. QR Codes may be used to display text to the user, to open a URL, save a contact to the address book or to compose text messages. A QR code once generated cannot be changed. Hence they can be used for the encryption of any important case data in Pega.
QR Code Generation in Pega:
We will now get to know how to generate a QR code for a specific property in your case type. Here we have generated a QR code for case ID. We can also create our own QR code for any property we want just by entering the proper property name.
I. Activity for QR Code generation: 1. Create a new activity by clicking Create > Technical > Activity. Enter the activity name, Class and click create and open.
2. Initially set the parameter values and define the pages and classes in the respective tabs accordingly.
3. In the steps tab define all the methods required for the generation of QR Code.
4. Initially define all the properties such as width, height, file name, file type and the file path using the Property-Set method.
5.Insert a 'Java' method in the next step. This java method generates the QR code.
6. Insert another 'Java' method to convert the QR code previously generated into an image file.
7. Add a 'Page-New' Method in the next step create a page on the clipboard. The system creates a new page as specified, using the name in the Step Page column of the step. Here the page name is 'ContentPage' as we defined in the Pages and Classes tab.
8. Add another Property-Set method to define all the property values including the Ruleset, Date-time and Description.
9. Insert the 'Obj-Save' method to save the record to the database.
10. Insert the 'Property-Set' method to set the image in the content page to the property that will be used in the section.
11. Add 'Page-Remove' to flush out the data currently present in the step page.
12. Add 'Log-Message' step to display a message.
II. Data Page:
13. Create a Data Page named 'QRCode' and define the structure, object type, scope in the data page definition section.
14. In the Data sources section specify the source as Activity and select the QR Code generator activity created initially.
III. UI for displaying QR code:
15. Create a section for QR code display and insert a Label property. The value of the label should be the source of the image.
<img broder=0 src="datacontent/Image/qrcode/<pega:reference name=".OutFileName"/>.png" />
16. Refer this section as an embedded section in the main UI section.
17. In the Page Context of the General tab select Use Data Page and Specify our DataPage name.
18. In the datapage parameters give .pyID to generate the QR Code for the Case ID value. (Any property for which the QR is to be generated can be used)
19. Run the case type and check the output.
While the QR Code is scanned using any scanner the recognition result returned is the Case ID of the case.
HAPPY LEARNING !!!