How do I pass a lead email address to an IFRAME? I did the following steps:

Created a new test lead.

Went into gear icon > Setup > Custom Code > VisualForce Pages, and created a new VisualForce Page like so:

  <apex:iframe src="https://example.com/salesforce/test.php?id={!$CurrentPage.parameters.id}" scrolling="true" id="iframe-test"/>

In my test.php page on my web server, I added this:

header('Content-Type: text/plain');
echo "\n\nDONE";

Exited setup.

Clicked on my lead (to show a single lead) and chose gear icon > Edit Page.

Added a new tab beside News called CUSTOM.

Clicked that tab in the page editor and dragged a VisualForce (page object) to that tab and set it to my new custom VisualForce page that I created.

Saved and Activated this change for the Org.

Exited the page editor to return to the single Lead view.

Clicked the CUSTOM tab.

Okay, so I can see an ID is passed to me of the calling page. However, is there an easy way to pass URL parameters to my IFRAME such as:


And, moreover, can these be URL-encoded so that they pass properly to my IFRAME?

Note I was able to get something like {!$ObjectType.Lead.Fields.Email} to give me an email, but it appeared in an unusuable format like the following when I viewed it in my IFRAME:


1 Answer 1


The trick is to change the APEX code to use the Lead standard controller, and then the Email is pulled with {!URLENCODE(Lead.Email)}.

<apex:page standardController="Lead">
  <apex:iframe src="https://example.com/salesforce/test.php?id={!$CurrentPage.parameters.id}&email={!URLENCODE(Lead.Email)}" scrolling="true" id="iframe-test"/>

That will give you the safe, URL-encoded version of the Lead.Email string.

Other parameters you can get with the Lead object are:


Note, however, that when you convert this Lead into a Customer, it will disappear from Leads and will be available under Contact. So, you have to repeat this process all over again to customize the Contact page. (Note that the Contact page doesn't contain Leads, by the way -- only converted customers.)

So, in the APEX code, it would look like:

<apex:page standardController="Contact">
  <apex:iframe src="https://example.com/salesforce/test.php?id={!$CurrentPage.parameters.id}&email={!URLENCODE(Contact.Email)}" scrolling="true" id="iframe-test"/>

As you can see, I switched Lead with Contact in the above code. Fields such as Email, MobilePhone, Phone, Name, FirstName, and LastName are all accessible under Contact just as they are under Lead.

The full Contact object reference is here:


You must log in to answer this question.

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