0

this is class

global with sharing class treeInlineController { 
  public String actId{get;set;}

    public treeInlineController(ApexPages.StandardController sc){
        List<Attachment> attachedFiles = [select Id from Attachment where parentId =:sc.getId() order by LastModifiedDate DESC limit 1];
        if( attachedFiles != null && attachedFiles.size() > 0 ) {

            actId = attachedFiles[0].id;
            System.debug('@@@@@@ '+actId);
        }
    }
}

this is page

<apex:page standardController="Folder_Items__c" extensions="treeInlineController" showHeader="false" sidebar="false" standardStylesheets="false">
  <iframe src="/servlet/servlet.FileDownload?file={!actId}" frameborder="0" width="100%" height="400px"/>
</apex:page>
0

Your ApexPages.StandardController should reference to the Folder_Items__c object defined as standard controller on the visualforce page. You can not use Folder_Items__c.ID for another object, for example Attachment. You better should change Folder_Items__c to Attachment.

  • kindly send me code which you have suggested to do – Vipin Indora Jan 20 '16 at 7:35
  • @VipinIndora You should use standardController="Attachment" – Sergej Utko Jan 20 '16 at 7:36
  • still same error show Id value 015d0000009LcU3 is not valid for the Attachment standard controller – Vipin Indora Jan 20 '16 at 7:38
  • @VipinIndora You should use this page on the Attachment page layout. The rule is: the same standard controller for the same object page layout. – Sergej Utko Jan 20 '16 at 7:40
  • i use on this attachmenr page layout but error show Content cannot be displayed: Id value a1Cd000000MyDGK is not valid for the Attachment standard controller – Vipin Indora Jan 20 '16 at 7:49

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.