You need to sign in to do that
Don't have an account?

printing QR code in Visual force with apex:image...
Hello,
I'm stuck probably in Syntax Error.
I try to print a QR Code in a VF Page.
This is the formula field content of the field in the custom Object:
I try to output with the following:
The XXXXXXX part stands for the domain and "&ID" should be the record ID, from with I call the VF page with a button.
I can enter the domain staticly, but it would be nice, if it could be fetched from the instance.
Thanks for your Help.
Rainer
I'm stuck probably in Syntax Error.
I try to print a QR Code in a VF Page.
This is the formula field content of the field in the custom Object:
IMAGE('https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=https://XXXXXXX.my.salesforce.com/'&Id,'Scan QR code to open record in mobile.')This works fine in the record.
I try to output with the following:
<apex:image id="QR" value="https://chart.googleapis.com/chart?chs=100x100&cht=qr&chl=https://XXXXXXX.my.salesforce.com/&ID" width="100" height="100"/>I tried several syntax variations with " and ' at different positions, but nothing worked.
The XXXXXXX part stands for the domain and "&ID" should be the record ID, from with I call the VF page with a button.
I can enter the domain staticly, but it would be nice, if it could be fetched from the instance.
Thanks for your Help.
Rainer
If you have a controller assigned to this visualforce page, do the following in the controller:
Controller ABC:
public class ABC{
public custom_object record {get; set; }
record = [ Select FF from custom_object where Id:= id;] }
Visualforce Page:
Use the below to call the QR code image:
<apex:outputText value="{!record.FF}" escape="false"/>
You mentioned you wish to update the domain name automatically in the formula field: This can be made possible through a trigger where you will have to first get the domain of your org using the below call:
String domainname =URL.getSalesforceBaseUrl().getHost().replace('.my.salesforce.com',''); //this will give you the mydomain set in your org
You can save this domainname value in a custom field and use it in the formula field to move away from hard coding the domain.
All Answers
If you have a controller assigned to this visualforce page, do the following in the controller:
Controller ABC:
public class ABC{
public custom_object record {get; set; }
record = [ Select FF from custom_object where Id:= id;] }
Visualforce Page:
Use the below to call the QR code image:
<apex:outputText value="{!record.FF}" escape="false"/>
You mentioned you wish to update the domain name automatically in the formula field: This can be made possible through a trigger where you will have to first get the domain of your org using the below call:
String domainname =URL.getSalesforceBaseUrl().getHost().replace('.my.salesforce.com',''); //this will give you the mydomain set in your org
You can save this domainname value in a custom field and use it in the formula field to move away from hard coding the domain.
thx for yor help. Managed to get the QR output with a direct <apex:outputText value="{!Object.Field}" call. But only in HTML. Will not be renderedAs PDF. I guess this is a known limitation.?
I will try your method, if that helps to create PDF with the QR code.
Thanks also for your help with the domainname in formular field!
Cheers
Rainer
To dynamically generate a QR code image URL within your Visualforce page and include the Salesforce instance URL, you can use a combination of Apex and Visualforce. Here's a revised code snippet:
Create a Visualforce page: Create an Apex controller (or extension) for your Visualforce page: This code fetches the instance URL dynamically and constructs the QR code URL with the record Id.
Moreover, for a more in-depth grasp of generating QR codes in Salesforce, I suggest visiting https://arrify.com/salesforce-qr-code-generator/. This resource provides a thorough guide on creating QR codes for Salesforce objects using a formula field and the Google API,complete with practical use cases. Don't missed it out!