How to generate a barcode or QR code image in Salesforce

Gimbal Barcode provides two options for generating barcodes: a PNG image that is stored as a Salesforce Content File (ContentDocument) or a Base64 string, or a barcode rendered within a Visualforce page using a Visualforce Component. This page covers the PNG image. For Visualforce, see How to render a barcode on a Visualforce page.

Steps

  1. Insert a Barcode Request record (Salesforce sObject of API name GMBLBC2__Barcode_Request__c). You can create it with any of the standard Salesforce mechanisms for creating records:
    • Manually, by navigating to the Barcode Request tab and clicking New
    • Declaratively, using automation tools such as Flow or Omniscript
    • Programmatically, using Apex
  2. Populate the INPUT fields (see the table below). Barcode Type and Barcode Value are required. Output Type defaults to FILE if left blank.
  3. Gimbal Barcode processes the inserted record. Depending on the Output Type, it either attaches the resulting image as a ContentDocument linked to one or more records (FILE), or writes the Base64 string data to a field on the Barcode Request record (BASE64).
  4. Check the Status field. It defaults to New when the record is created, and Gimbal Barcode updates it to Success or Failure once processing completes.

Barcode generation is asynchronous. A single barcode request typically completes in under one second, but large batches (for example, hundreds of barcodes at once) may take longer. Do not assume the OUTPUT fields are populated immediately after the record is saved or inserted. Refresh the page and/or check the Status field to confirm processing has completed.

Barcode Request fields

INPUT fields are populated by the user (or by automation/Apex) to define the barcode to be generated. OUTPUT fields are read-only and populated by Gimbal Barcode once processing completes.

Field Type INPUT / OUTPUT Description / How to Populate
Barcode Type Picklist INPUT Required. The barcode symbology to generate: code128, code39, datamatrix, ean13, gs1-128, gs1datamatrix, interleaved2of5, pdf417, qrcode, upca, or other. Gimbal Barcode supports 100+ symbologies; select other for anything not listed, and consult the documentation or contact support@gimballogic.com.
Barcode Value Text INPUT Required. The data to encode in the barcode (e.g. a SKU, serial number, or URL).
Output Type Picklist INPUT Defaults to FILE if left blank. FILE saves the barcode image as a Salesforce Content File. BASE64 returns the image as a Base64-encoded string on the record.
Extra Params Text INPUT Optional. Well-formed JSON specifying additional formatting or content options, e.g. {"includetext":true,"padding":"5","backgroundcolor":"FFFFFF"}.
File Name Text INPUT Optional; used only when Output Type = FILE. Name of the File that will be created. Defaults to "barcode" if left blank.
Linked Record IDs Text INPUT Optional; used only when Output Type = FILE. Comma-separated list of record IDs to relate the File to (e.g. an Account ID, or a public library ID for Salesforce Document Generation).
Status Picklist OUTPUT Defaults to New when the record is created. Gimbal Barcode updates this to Success or Failure once processing completes.
Message Text OUTPUT Populated with an error message if barcode generation fails. Blank on success.
Base64 Image Data Text OUTPUT Populated with the Base64-encoded barcode image when Output Type = BASE64.
Content Document ID Text OUTPUT Populated with the ID of the Content Document created when Output Type = FILE.
Content Version ID Text OUTPUT Populated with the ID of the Content Version created when Output Type = FILE.

Using the image in document generation

Most document generation solutions (e.g. Salesforce Document Generation, Conga, etc.) will require the Content File to belong to a File Library to which the document generation solution has access. Make sure to include the ID of the File Library in the "Linked Record IDs" field.


Related pages: Create a barcode from the Barcode Request tab | Create a barcode with Flow or Omniscript | Create a barcode with Apex | QR Codes, Simplified, and Fully Native in Salesforce

Start here | Full configuration guide (PDF, version 8.14) | Questions: barcode@gimballogic.com

Create barcode image files (about 3 minutes)