function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anurag Sharma 244Anurag Sharma 244 

At inline VF page.. i want to display the image. Sort it out with the help of code.

Accourding to the requirement at contact detail view.. inline vf page will show.
and then image will display there... but user can attach more than one image too.. so i need to show the last image only.
so anyone please help me to code.
AshwaniAshwani
Can you post some code of visualforce page.  
Anurag Sharma 244Anurag Sharma 244

here is the code..... so i need to merge it.... and display the last image.
For inline VFpage.....

<apex:page standardController="contact" extensions="InlineVFPageController">
  <apex:pageBlock>
      <apex:pageBlockSection>
          <apex:pageBlockSectionItem>
              <apex:outputLabel>First Name</apex:outputLabel>
              <apex:outputField  value="{!conDetail.firstname}"/>
          </apex:pageBlockSectionItem>
          <apex:pageBlockSectionItem>
              <apex:outputLabel>Last Name</apex:outputLabel>
              <apex:outputField  value="{!conDetail.lastname}"/>
          </apex:pageBlockSectionItem>
         
      </apex:pageBlockSection>
  </apex:pageBlock>
</apex:page>

Class code for inline vfpage...

public class InlineVFPageController{
    public contact conDetail{get;set;}
    //Constractor
    public InlineVFPageController(ApexPages.StandardController obj){
       Contact  con = (contact) obj.getRecord();
       conDetail = [select firstname,lastname from contact where id =: con.id];
    }
}

 

For attachment...
//class code

public class AttachmentController{
    public contact con{get;set;}
    public attachment att{get;set;}
    //Constructor
    public AttachmentController(){
        con = new contact();
        att = new Attachment();
       
    }
    public pageReference save(){
        insert con;
        att.parentId=con.id;
        insert att;
        //return new pageReference('/'+con.id);
        return null;
    }
}
//Page Code
<apex:page controller="AttachmentController">
  <apex:form>
      <apex:pageBlock>
          <apex:pageBlockSection>
              <apex:inputField value="{!con.lastname}"/>
              <apex:inputField value="{!con.city__c}"/>
              <apex:inputFile fileName="{!att.name}" value="{!att.body}" contentType="{!att.contentType}"/>
              <apex:image value="/servlet/servlet.FileDownload?file={!att.id}"/>
          </apex:pageBlockSection>
          <apex:commandButton value="Save" action="{!save}"/>
      </apex:pageBlock>
  </apex:form>
</apex:page>