0

I have the following issue. I would like to create a lot of survey invitations at once, and generate for them QR code to patient which will receive the survey by post will have possibility to scan and open. So by standard salesforce tool I create survey invitations, and then, in formula I would like to generate a QR code.

It's working, QR code is generated but with small problem - when I try to pass the parameters in the image link, then after the & there are amp; characters. Have anyone idea, how can I avoid adding the amp; code in the formula?

Formula code:

IMAGE("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=MYLINK?invitationId="
                        + Id
                        + "&surveyName=patient_survey" 
                        + "UUID=" +UUID ,'')

And the URL link after record created:

<img src="https://chart.googleapis.com/chart?chs=150x150&amp;cht=qr&amp;chl=https:MYLINK?invitationId=0Ki5E0000007Mew&amp;surveyName=patient_surveyUUID=9da26120-686c-4d63-b4c1-0f2ccb379a54" alt=" " border="0"/>

1 Answer 1

1

It isn't adding amp;, it's replacing & with &amp;. This is how special characters are encoded in HTML. For the purposes of HTML, & and &amp; are equivalent. Another example is ' encoded as &apos;.

For additional context, see here: Do I really need to encode & as &amp;?

The problem lies not in Salesforce, but with the Google QR Code Generator. If you have URL parameters in your URL, you will need to use %26 instead of &, so that the Google API sees them as part of the URL for the QR code.

Your formula would then look like:

IMAGE("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=MYLINK?invitationId="
                        + Id
                        + "%26surveyName=patient_survey" 
                        + "%26UUID=" + UUID, '')
4
  • 1
    Okay, I understand, but still it is the problem, as the &amp; is destroying my URL for QR code which is not working
    – Qba2312
    Commented Nov 21, 2023 at 9:49
  • Hi @Qba2312, it looks like the Google QR generator is ignoring the & in your link. You need to URL encode them with %26. (Also I think you are missing a & before the UUID parameter)
    – fred
    Commented Nov 22, 2023 at 12:42
  • Also I assume you are replacing MYLINK with something?
    – fred
    Commented Nov 22, 2023 at 13:01
  • Hi @Fred, it's working partially now. So the %26 helped, but the problem is still existing. And in the second, you are right also, under MYLINK there is link to the survey invitation to open and fill the survey. I mean, it's working partially because if I create survey as 'don't require authentication' and 'unique link', then the survey is opening with following error: "To access this survey, ask your Salesforce admin for permission
    – Qba2312
    Commented Nov 22, 2023 at 15:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .