1

I'm trying to embed a visualization/chart from an external SQL tool via a VisualForce iframe section on the Salesforce Account page layout. To do this, I need to append the account name into the SQL report URL.

I've managed to get the VisualForce page setup to display the visualization/chart properly, but I'm having trouble with my Controller to have it pull the Account Name of the current account page.

Any help to get this working would be greatly appreciated.

<apex:page standardController="Account">
<iframe src="https://modeanalytics.com/reports/bca8c3be75b6/runs/be5b8b8f62c0/?run=now&param_domain={!Account.Name}" width="100%" height="400" frameborder="0"></iframe>
</apex:page>
  • I'm having trouble with my Controller to have it pull the Account Name of the current account page. you want to get current Account Name? as per your above code looks like you r not using extension controller – Ratan Paul Jan 9 '16 at 9:01
  • 1
    Did you set the id parameter in the url when viewing the page? – martin Jan 9 '16 at 9:07
  • are you running into this issue - help.salesforce.com/… ? (see Browser tools console) – cropredy Jan 9 '16 at 19:35
  • Thanks for these replies. Admittedly I'm pretty new to working with controllers and extensions. How does one set the id parameter? I assume that is the account record ID? – Alex Miller Jan 11 '16 at 17:31
1

Apart from the addition of URLENCODE to handle cases where the Account name included e.g. spaces:

<apex:page standardController="Account">
<iframe src="https://modeanalytics.com/reports/bca8c3be75b6/runs/be5b8b8f62c0/?run=now&param_domain={! URLENCODE(Account.Name) }" width="100%" height="400" frameborder="0"></iframe>
</apex:page>

as martin pointed out you do need to supply an Account ID as otherwise the standard controller thinks it is working on a new Account that doesn't have an ID or name. So the request URL needs to be of this form:

/apex/YourPageName?id=001i000000UBpmI

where 001i000000UBpmI is an existing Account ID. This will successfully add the Account name to the iframe URL.

| improve this answer | |
  • Keith -- I understood the OP has a "standard" Account pagelayout with an embedded VF page, so the /apex/yourPageName?.... construction doesn't apply. Or am I missing something here? Standard account View page will implicitly have the account Id – cropredy Jan 9 '16 at 19:20
  • @crop1645 You are right - I didn't read the question carefully enough. – Keith C Jan 9 '16 at 19:45
  • correct - I have a standard account page layout with an embedded VF page. Coincidentally, all of our Account Names are in an email domain format (apple.com, salesforce.com, etc.) so there shouldnt be any additional formatting necessary. – Alex Miller Jan 11 '16 at 17:28
  • @AlexMiller Just FYI, the @ symbol is encoded as %40 by a lot of encoding utilities such as JavaScript's encodeURIComponent. – Keith C Jan 11 '16 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.