0

I'm trying to build a VF page using the Account standard controller, but the only Id I can pass into the page is a Contact Id. Is there any way to pick up that Id, grab the associated Account Id and then feed the controller that way?

EDIT: This page is being used in a managed package that allows VF pages to be used. However, the tool limits what you can feed into the URL:

enter image description here

The example above shows what I'm allowed to pass into the URL -- and ID only refers to the Contact's Id. I tried to add the {!Contact.AccountId} variable, but it doesn't work.

EDIT EDIT: Here's what I get in the tool when trying to view the VF page (it's a widget within the broader tool, essentially dropped in as an iframe):

enter image description here

<apex:page standardController="Account" sidebar="false"  showheader="false">   
    <apex:form >
        <div style="width: 405px; margin: 0 auto; padding: 10px 0 10px 0">
            <div style="margin-right: 5px; width: 35px; display: inline"><apex:commandButton value="Save" action="{!quicksave}" id="saveButton" /></div>
            <button style="width: 120px; margin-right: 5px" onclick="window.open('https://www.linkedin.com/company/{!Account.Name}')">Account's LinkedIn</button>
        </div>    
        <apex:pageBlock >
            <apex:pageBlockSection title="Account Details" columns="2">

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Account Name"/>
                <apex:outputField value="{!Account.Name}"/>
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Account Owner"/>
                <apex:outputField value="{!Account.Owner.Name}"/>
                </apex:pageBlockSectionItem>                                

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Account Type"/>
                <apex:outputField value="{!Account.Type}"/>
                </apex:pageBlockSectionItem>                

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Pipeline Rep"/>
                <apex:outputField value="{!Account.Pipeline_Rep__c}"><apex:inlineEditSupport event="ondblClick" /></apex:outputField>
                </apex:pageBlockSectionItem>                 

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Planet"/>
                <apex:outputField value="{!Account.Planet__c}"/>
                </apex:pageBlockSectionItem>                    

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Employees"/>
                <apex:outputField value="{!Account.NumberOfEmployees}"/>
                </apex:pageBlockSectionItem>                    

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Open Opps"/>
                <apex:outputField value="{!Account.No_of_Open_Opportunities__c}"/>
                </apex:pageBlockSectionItem>                           

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Closed/Won Opps"/>
                <apex:outputField value="{!Account.No_of_ClosedWon_Opportunities__c}"/>
                </apex:pageBlockSectionItem>                

                <apex:pageBlockSectionItem >
                <apex:outputLabel value="Closed/Lost Opps"/>
                <apex:outputField value="{!Account.No_of_ClosedLost_Opportunties__c}"/>
                </apex:pageBlockSectionItem>    

            </apex:pageBlockSection>           
        </apex:pageBlock>
    </apex:form>
</apex:page>
  • What do you mean you can only pass a Contact Id? Please clarify the observed behavior for any relevant inputs. – Adrian Larson Jul 27 '17 at 18:18
  • @AdrianLarson added more context to the post. It's through a managed package that has me specify a URL to the VF page and only allows me to pass the Contact Id in via the URL – Matt Jul 27 '17 at 18:30
  • You pass an Account Id in your screenshot... It's still unclear what behavior you observe. Are you getting errors? Does it load? – Adrian Larson Jul 27 '17 at 18:31
  • @AdrianLarson sorry -- added another edit to show exactly what I'm seeing. "Id value is not valid for the Account standard controller" – Matt Jul 27 '17 at 18:40
  • Viewing the source, this is the URL being passed: XXXX.my.salesforce.com/apex/XXXX_Custom_Account_Fields?id={!Contact.AccountId}&amp;widget=1 so it looks like the variable isn't being populated due to the tool's limitation – Matt Jul 27 '17 at 18:44

Your Answer

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

Browse other questions tagged or ask your own question.