QR vCard for Contacts
This hack generates a QR code containing a contact’s information in vCard format, allowing users to quickly scan and save the details on their mobile devices.
HACKS
Warning: This approach uses a free QR API to generate codes dynamically. Since the data is sent to an external service, it is best suited for corporate or publicly available information, avoiding the use of sensitive personal data.


To use this hack, create a new formula field in the Contact object with the return type set to Text, like the one shown in the Formula Explanation section. Add this field to the Contact Page Layout or Lightning page to display the QR code. When users scan this QR code, the contact information will be saved to their mobile devices.
Additionally, since the QR code is generated using an external service, you must add the domain https://api.qrserver.com to CSP Trusted Sites in Salesforce. Otherwise, the image may be blocked and not displayed in Lightning Experience.
Note that this version of the formula does not include substitutions for special characters, meaning that any special characters present in the data fields are not encoded. This can cause issues if the fields contain characters that need to be URL-encoded.
Configuration


1. IMAGE Function:
IMAGE(url, altText): This function displays an image from the specified URL. The URL is generated dynamically to include vCard data.
"QR Code" is the alternative text for the image.
2. QR Code Generation URL:
"https://api.qrserver.com/v1/create-qr-code/?size=125x125&data=": This is the base URL for generating a QR code. The size of the QR code is set to 125x125 pixels, and the data parameter is used to include the vCard information.
3. vCard Data:
vCard Start and Version:
"BEGIN:VCARD%0AVERSION:3.0%0A": Marks the beginning of the vCard and specifies the version as 3.0. %0A represents a newline character.
Name Fields:
"N:" & LastName & ";" & FirstName & "%0A": Specifies the structured name, with the last name followed by the first name.
"FN:" & FirstName & " " & LastName & "%0A": Specifies the formatted name, combining the first name and last name.
Organization:
"ORG:" & Account.Name & "%0A": Includes the organization (company) name.
Title:
"TITLE:" & Title & "%0A": Includes the title (job title).
Phone Number:
"TEL;TYPE=WORK,VOICE:" & Phone & "%0A": Specifies the work phone number.
Email Address:
"EMAIL;TYPE=PREF,INTERNET:" & Email & "%0A": Specifies the preferred email address.
Address:
"ADR;TYPE=WORK:;;" & MailingStreet & ";" & MailingCity & ";" & MailingState & ";" & MailingPostalCode & ";" & MailingCountry & "%0A": Specifies the work address, formatted as per vCard standards.
vCard End:
"END:VCARD": Marks the end of the vCard data.


