0
votes

I need to customize the contact page with some custom fields.

On the Contact page I want to include some custom fields which could be populated by a web service call using apex and while calling the page I should be able to pass the specific parameter to the apex code in order to call the webservice ?

In short I dont have value of this fields stored in the salesforce database I have some code(apex code that needs to be called for this). and get the value from a different system. whether it is possible and how ?

Any Help will be greatly appreciated

1

1 Answers

1
votes

It is possible to embed visualforce pages onto page layouts. So I would recommend creating a visualforce page like the example below. Use the apex code you already have that is performing the webservice callout as the controller extension for this page and you'll be able to show the fields.

The only thing I'm unclear about is what specific parameter do you want to pass to your webservice? and how is it being passed to the contact page currently? If it's just a url parameter, your controller extension will have access to it using the ApexPages class. If it's the Id of the contact the constructor of the controller extension will be able to get it from the StandardController parameter.

Some important things to note:

  • the visualforce page must use the Contact standardController for it to be available as an embeddable visualforce page.
  • If the contact view action is already overridden the embedded visualforce page will not render. However if the page is already overridden you wouldn't have this problem because you could add the required code straight to the override page.

    <apex:pageBlock id="block">
        <apex:pageBlockSection id="section">
            <apex:pageBlockSectionItem id="item">
                <apex:outputLabel value="External Value:" for="externalValue" />
                <apex:outputText id="externalValue" value="{!externalField}" />
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>