Implement a QR Code Custom Form Element using a Third Party Library
Implementing a custom form element allows you to augment the existing form elements that come with Geocortex Workflow.
This article will walk you through creating a form element that uses the qrcode library to generate and display a QR code.

#
PrerequisitesFollow the instructions in the Web Applications SDK page to set up your development environment.
note
A working knowledge of TypeScript is recommended before extending Workflow for web-based hosts.
#
OverviewImplementing a QR code custom form element for web applications using a third party library consists of the following steps:
- Adding third party library dependencies to your project.
- Creating the custom form element.
- Implementing the custom form element using the third party library.
#
Adding Dependencies- Run
npm install qrcode
in the terminal to install the third party qrcode library that generates QR codes. - Run
npm install @types/qrcode
in the terminal to install type information for the third party library. This is optional, but it provides an improved developer experience.
#
Set up Custom Form Element SkeletonTo create a new form element:
- Open the Workflow activity SDK in Visual Studio Code.
- Run
npm run generate
in the terminal. - When prompted, select
Form Element
. - Enter the name of the form element you would like to create and press
Enter
. For example,QrCode
. - Open the newly created
src/activities/QrCode.tsx
file.
#
Implement the Custom Form ElementModify the skeleton form element implementation in src/activities/QrCode.tsx
to match the following example.
#
Deploy the Form ElementFollow the instructions to build and deploy the activity pack.
#
Test the Form ElementOnce your activity pack is hosted and registered, your Register QrCode Form Element
custom activity should appear in the activity toolbox in Geocortex Workflow Designer alongside the built-in activities.
To use your custom form element in a workflow:
- Add your
Register QrCode Form Element
custom activity to your workflow so that it runs before anyDisplay Form
activities that will use the custom form element. - Select the
Display Form
activity that you want to include your form element in. - Add a
Custom
form element to the form. - Set the
Custom Type
property of theCustom
form element toQrCode
. - Add a
load
event subworkflow to the form element. - Add a
Set Form Element Property
activity to the subworkflow. - Set the
Property Name
input tovalue
. - Set the
Property Value
input to the text that represents the data or URL to encode into the QR code. - Test your workflow.
#
Next StepsLearn how to create a QR Code activity
Learn how to to use this same third party library to create an activity that creates QR codes