简体   繁体   中英

Create a custom page block in the entities tab of Salesforce

I am using REST API to access salesforce using java code . There is an 'entities' tab in my salesforce account . I need to place a custom page block within this tab page to display a png image that I have loaded to salesforce .

I know that custom pages can be created through visualforce markup language and apex classes which access data from the standard objects found in salesforce . But these are for creating entirely new pages , whereas I need to add a custom page block for the 'entities' tab page .

Can I edit the visualforce markup for the 'entities' tab to add my new section to display my image . If yes how . Are there any better way to acheive this .

I have gone through most of the documents regarding this topic on the web . But this is getting me utterly confused .

The entities tab is actually the representation for the Accounts standard object. My requirement was to call a custom made visualforce page when I click any account name.

This is what I did to fullfill this requirement. I created a visualforce page with the with the following code : -

<apex:page standardController="Account" extensions="AccountImageController">
<apex:pageBlock title="BluePrint Image">
    <apex:form >
        <apex:image url="/servlet/servlet.FileDownload?file={!FileId}"/>
    </apex:form>
</apex:pageBlock>
<apex:detail />

This will basically display the image that I had uploaded as an attachment to some of the accounts . As you can see that it references an apex class which looks like this .

Public Class AccountImageController {

String recId;

public AccountImageController(ApexPages.StandardController controller) {
    recId = controller.getId();    
}

public String getFileId() {
    String fileId = '';
    List<Attachment> attachedFiles = [select Id from Attachment where parentId =:recId order By LastModifiedDate DESC limit 1];
    if( attachedFiles != null && attachedFiles.size() > 0 ) {
        fileId = attachedFiles[0].Id;
    }
    return fileId;    
}

}

Now I override the link for the account standard object and link it to the above visualforce page. Save it and click on the client/account tab . Click on any account name and the image is shown as a custom page block .

I assume people reading this are already fimiliar with the basics of salesforce which is required to create a visualforce page , apex classes and to override the links in the accounts tab .

For those who are not , please refer to the standard documentation or google for help . Hope this helps those who are stuck with this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM