How to create a barcode with Apex
Barcode Request records can be created programmatically with standard DML, just like any other sObject. As with the other methods, set only the INPUT fields.
Steps
- Create a
GMBLBC2__Barcode_Request__crecord and set only the INPUT fields. The example below creates a QR code from an Asset's serial number, saves it as a File named AssetLabel, and links the File to the Asset.
GMBLBC2__Barcode_Request__c req = new GMBLBC2__Barcode_Request__c(
GMBLBC2__Barcode_Type__c = 'qrcode',
GMBLBC2__Barcode_Value__c = myAsset.SerialNumber__c,
GMBLBC2__Output_Type__c = 'FILE',
GMBLBC2__File_Name__c = 'AssetLabel',
GMBLBC2__Linked_Record_IDs__c = myAsset.Id
);
insert req;
- If necessary, query the inserted Barcode Request record(s) after processing completes to retrieve the OUTPUT field values (e.g. Content Document ID).
Barcode generation is asynchronous, so the OUTPUT fields are not populated immediately after the insert. Check the Status field for Success or Failure. All fields are described on How to generate a barcode or QR code image in Salesforce.
Related pages: Generate a barcode or QR code image | Create a barcode with Flow or Omniscript | Render a barcode on a Visualforce page
Start here | Full configuration guide (PDF, version 8.14) | Questions: barcode@gimballogic.com