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
Vigneshwaran LoganathanVigneshwaran Loganathan 

Where to view attached image via visualforce page

Hi,

I have written a visualforce page and class for uploading attachement in Details__ c object.

Records are saving correctly in Details__c, but I wonder where the attechment goes.. Is there a specific path to view those attachements?

Help plz.


Thanks,

sandeep sankhlasandeep sankhla
Hi Vignesh,

If you have attached document correctly then simply you can go to object detail page and in related list those should be visible..Please check and let me know if you are able to see..

may b you are not able to scussefully attach them to Details object so ..It would be good if you can paste your code here so I can help you out..

Thanks,
Sandeep
Sanjay.GeorgeSanjay.George
Hi Vignesh,

All the attachements are saved under the attachment object with a parent id to 'Details__c'.

To view an attachment, use the following in VF :  {!URLFOR($Action.Attachment.View, <attachmentID>)}
Vigneshwaran LoganathanVigneshwaran Loganathan
Hi,

Guess I am going wrong somewhere, I dont see attachemnt in the detail page.. help plz .

My Class
 
public class Tandurecontroller {
public Boolean save{get;set;}
public String ssdid2 = ApexPages.currentPage().getParameters().get('id');
public tandure_domain__c dom{get;set;}
    public Tandurecontroller(ApexPages.StandardController controller) 
    {
       dom=new tandure_domain__c();
    }
   public Attachment attachment {
      get {
          if (attachment == null)
           attachment = new Attachment();
           return attachment;
          }
          set;}
      
  public Pagereference save1()
   {
     save=true;
     attachment.ownerId= userInfo.getUserId();
     attachment.parentId='01I90000001UHng';
     attachment.IsPrivate=true;
     try{
        insert attachment;
         }
     catch(DMLexception e)
       {
       ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
       }
       upsert dom;
      return null;
}}

VF
 
<apex:page standardController="Tandure_Domain__c" sidebar="false" extensions="Tandurecontroller">
 <apex:sectionHeader title="Tandture Systems" />
 <apex:form >
   <apex:pageblock >
   <apex:pageblockbuttons location="Bottom">
    <apex:commandButton value="Save" action="{!Save1}" disabled="{!save}"/>
   </apex:pageblockbuttons>>
   <a href="http://google.com"> <apex:image id="Tandture" value="https://ap1.salesforce.com/resource/1427874082000/Tandture" width="1200" height="300"></apex:image></a>
    <br></br><br></br><br></br>
    <apex:pageblockSection title="Salesforce">
    
       <apex:inputField value="{!Tandure_Domain__c.name}"/>
       <apex:inputField value="{!Tandure_Domain__c.Email__c}"/>
       <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file"/>
    </apex:pageblockSection>
   </apex:pageblock>
  </apex:form>  
</apex:page>

Thanks,
 
Mudasir WaniMudasir Wani

Hi Vigneshwaran,

Please change the code on line 22 of your controller 
Save method code should be 
 
public Pagereference save1()
   {
     save=true;
     attachment.ownerId= userInfo.getUserId();
     attachment.parentId='01I90000001UHng';
     //changed below line 
     attachment.IsPrivate=false;
     try{
        insert attachment;
         }
     catch(DMLexception e)
       {
       ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
       }
       upsert dom;
      return null;
}


Please mark this as solution if this solves your problem, So that if anyone has this issue this can help.