You need to sign in to do that
Don't have an account?
apple_sae
How I can display my attachment ID in Visualforce page
Hi All,
I have query my attachment from my custom object using Relationship Queries,
but I don't know how I can display my attachment ID , I got error Save error: Unknown property 'VisualforceArrayList.id'
I have queries and VF page like this:
public class documentCls { public Id uid; public Integer counter{get;set;} public list<Document__c> lstDocument{get;set;} public list<Document_Version__c> lstDocVs{get;set;} public list<Attachment> Attach{get;set;} public documentCls(){ getlstDocument(); getlstDocVs(); } public void getlstDocument(){ uid = UserInfo.getUserId(); if(uid != ''){ lstDocument = [ SELECT Document__c.Id, Document__c.Name, Document__c.Document_Name__c, Document__c.Description__c FROM Document__c Where Document__c.OwnerId = :uid]; counter = [ SELECT Count() FROM Document__c Where Document__c.OwnerId = :uid]; System.debug('My counted records: ' + counter); } } public void getlstDocVs(){ if(lstDocument.size() > 0){ for(Document__c d:lstDocument){ lstDocVs = [SELECT Document_Version__c.Id,
Document_Version__c.Document__r.Document_Name__c, Document_Version__c.Document__r.Description__c, Document_Version__c.Document__r.CreatedDate, Document_Version__c.Document__r.LastModifiedDate, (SELECT Attachment.Id
FROM Document_Version__c.Attachments) FROM Document_Version__c WHERE Document_Version__c.Document__c = :d.id ORDER BY Document_Version__c.Document__r.CreatedDate DESC]; } }else{ system.debug('Document is null'); } } }
<apex:page showHeader="false" standardStylesheets="false" sidebar="false" Controller="documentCls"> <div class="tab-pane" id="your-documents">
<div class="doc-alert">You have {!counter} new document ready for download!</div>
<apex:repeat value="{!lstDocVs}" var="v">
<ul class="doc-steps">
<li>
<apex:outputText value="{!v.Document__r.Document_Name__c}"/>
<apex:outputLink value="{!URLFOR($Action.Attachment.Download,Attachments.id)}" target="blank">
Preview
</apex:outputLink>
</li>
</ul>
</apex:repeat>
</div>
</apex:page>
Thanks for any help
Attachments is a related list on Document__c, so you can't treat it as though its a single instance. I also think you need to prefix it with the var from your apex repeat.
I think you'll need to iterate the attachments in a similar way that you do the documents. Something like:
All Answers
Attachments is a related list on Document__c, so you can't treat it as though its a single instance. I also think you need to prefix it with the var from your apex repeat.
I think you'll need to iterate the attachments in a similar way that you do the documents. Something like:
Hi bob,
Thank you for your reply, I have tried doesn't work I'm not get any error but Document Name and ID is disappear,
Thanks,
Apple
What does the rendered html look like?
I got a blank page, nothing appear I try to do somethink like this and still not working, too.
So if you view the source of the page, there is no HTML?
Yes,I got this when view HTML source:
Looking at your code this is entirely possible - you are only retrieving the last document in the list and its attachments.