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
llisallisa 

Declare two attachments in a apex program.

Hello Everyone,

My query is how to differenciate two attachment i.e 2 list for two different attachments in two different page block section..
public List<Attachment> attachments{get;set;}
public List<Attachment> attachments1{get;set;}

Here i create Two different Pageblock Section for both of the attachments.but the problem is that
- i am unable to differenciate both the attachments i.e both page blocksections fetch same data from both attachments.

So give some idea how i differenciate this two different attachments?
ManojjenaManojjena
Hi llisa,

You need to differentiate teh attchments while assigning to the list .Can you explain your requirment with bit more clarity for solution .

Thanks
Manoj
sslodhi87sslodhi87
Can you please mention the condition here, which can help us to answer in more specific?
llisallisa
Hi Manoj,

Thanks for your reply.
1.The Senario is i have 2 different pdf attachments which are related to 2 different buttons.i.e by clicking those buttions there respective pdf will generate and stores in its respective page block section in custom detail page.

2.But here my problem is i am unable to differenciate this two pdf in two diffn page block section.

i declare 2 diffn list
public List<Attachment> attachments{get;set;}
public List<Attachment> attachments1{get;set;}  for 2 pdf.

3. to display those pdf in cuatom detail page i wrote query

attachments=[select id,name,Body,CreatedDate from Attachment where parentId=: documentId Order By CreatedDate Desc];
       attachments1=[select id,name,Body,CreatedDate from Attachment where parentId=: documentId Order By CreatedDate Desc];

4. so now to create one pdf if i click its respective button the pdf is generated and stores in both pageblock section insteed of its respective one.