Creating QR codes for an Object

The attached lambda code (fndy-create-qrcode-prod) will:


  • Create a QR code
  • Save it to an specified S3 Bucket
  • Set an attribute on the device called "qr_code" to the path of QR code in the S3 Bucket


Create The lambda Function

  • Node.js 8.10
  • Role: LambdaFunctionRole
  • set the timeout to 1 minutes
  • Required Environment variables “ENV”

    ENV = dev | prod | stage





Sample Payload

{
  "body": {
    "deviceId": "3bb66330-b79c-11e8-b89d-3b0f0cc2c214",
    "attribute": "a.name",
    "bucket": "ZestImageBucket"
  }
}


  • deviceId = the device that you want to create an QR code
  • attribute - the name of the attribute that you want to include as part of the data encoded into the QR code
  • bucket - name of the S3 bucket where the QR code will be stored


Structure of link to QRcode


The filename with QR-code uses: 

“<uuid>.<extension>”, example:  00b4f168-2b2c-11e8-9906-2aaa7fc2b41d.png

Inside the bucket, the image is placed in the directory “<Environment>-QRCode”, example:  dev-QRCode


Example attribute "a.qr_code" and link QRCode in device



Functionality

  • The Lambda function will generate a QR code, and save it in the designated buck
  • it will populate an attribute called "qr_code" with the URL to the S3 Bucket
  • Normally would be executed on "insert" of the object
  • also, might want to make the "icon_image" field a formula field that copies the "qr_code" field, so the QR code appears on the detail page.



Printing the QR Codes


The second lambda function can be used to create a PDF of all the QR codes so that you can print them out on 8.5x11 sheet of paper six per page (pdf-toPrint-qr_code.zip).


Since you'd typically only run this one time, you can install the Lambda and then just run it from the Test configuration of the Lamba


Sample Payload

{
  "body": {
    "bucket": "foundry-qr-codes-hammermillstorage",
    "path": "prod-QRCode/"
  }
}


Bucket  - the name of the S3 bucket where the QR codes are located

path - the name of the S3 bucket with in the "bucket" where codes are located


Link to Lambda to create QR codes

https://drive.google.com/file/d/1GiZwPf8n2f1FzgaZ1o4PRw9FkOZxIMf1/view?usp=sharing


This is the link to the Lambda Function use to print the QR codes

https://thinglogix.freshdesk.com/solution/articles/16000084994-creating-qr-codes-an-object