"Notes and Attachments" related list doesnt seem to be customizable. What happens when you click on the "View" link in the first column instead of clicking on the title? Also I believe there is a browser setting to open all links in new tab/window - Each browser will have a separate setting to achieve that.
If you are talking about a custom VF Page and Controller, please post the code to assist.
This is the case if the attachement is in related list. -After opening that record you can click on "View" under "Action" in the related list. The file will either open in the browser or it will get downloaded.
Hope is what you wanted. Mark it as solution if it helps you out.
In my scenario if a opportunity had 20 attachments, i cant go to each view link it is very difficult to click on every attachment. So i need to create a button/ link when i click on that all the attachments need to open in a newtab.
I created a Button View, which takes the id of the opportunity /apex/ViewVFPage?id={!opportunity.Id}
I am learning development, if i do any wrong in dev please let me know.
In that vf page, <apex:page standardController="opportunity" extensions="test">
</apex:page> In Apex Class
public class test { public test(ApexPages.StandardController controller) { list<Attachment> ATT=[SELECT Id FROM Attachment WHERE ParentId = :ApexPages.currentPage().getParameters().get('Id')]; //system.debug('.......'+ATT.size()); For(integer i=0;i<ATT.size();i++){ //System.debug('++++++'+ATT[i]); PageReference attPage = new PageReference('https://c.cs5.content.force.com/servlet/servlet.FileDownload?file='+ATT[i]); } } }
I am unable to get those results and redirect those results. please help me in that
Try this example. I made a button in a VF page and assigned "customsave" to the "action" parameter of the button. You have to change code as per your need.
<apex:page standardController="Account" extensions="test"> <apex:pageBlock > <apex:form > <apex:commandButton value="Attachment" action="{!newWindow}"/> </apex:form> </apex:pageBlock> </apex:page> ---------------------------------------------------------------------------------------------------------------------- public class test { private final account acc; public Id attId;
public test(ApexPages.StandardController controller) { this.acc=(account)controller.getrecord(); act = ApexPages.currentPage().getParameters().get('Id'); listAct = [Select Id from Attachment where ParentId =: act];
}
public pagereference newWindow(){ pagereference newTab=new pagereference('/servlet/servlet.FileDownload?file='+listAct[0].Id); return newTab; }
Public string act{get; set;} List<Attachment> listAct = new List<Attachment>();
I tried with this model, It wont work for More than 1 attachment. it will openly only one attachment.
i tried using for loop
public class test {
private final account acc;
public Id attId;
public test(ApexPages.StandardController controller) {
this.acc=(account)controller.getrecord();
act = ApexPages.currentPage().getParameters().get('Id');
listAct = [Select Id from Attachment where ParentId =: act];
}
public pagereference newWindow(){
For(Integer i=0, att.size() > i,++i){
pagereference newTab=new pagereference('/servlet/servlet.FileDownload?file='+att[i].Id);
return newTab;
}
}
Public string act{get; set;}
List<Attachment> att= new List<Attachment>();
}
It was throwing this error
Error: test Compile Error: Illegal variable declaration: att.size at line 14 column 26
Please help me in this, to open multiple attachments using single button
Also I believe there is a browser setting to open all links in new tab/window - Each browser will have a separate setting to achieve that.
If you are talking about a custom VF Page and Controller, please post the code to assist.
This is the case if the attachement is in related list.
-After opening that record you can click on "View" under "Action" in the related list. The file will either open in the browser or it will get downloaded.
Hope is what you wanted.
Mark it as solution if it helps you out.
Thanks,
Shiv
In my scenario if a opportunity had 20 attachments, i cant go to each view link it is very difficult to click on every attachment. So i need to create a button/ link when i click on that all the attachments need to open in a newtab.
I created a Button View, which takes the id of the opportunity
/apex/ViewVFPage?id={!opportunity.Id}
I am learning development, if i do any wrong in dev please let me know.
In that vf page,
<apex:page standardController="opportunity" extensions="test">
</apex:page>
In Apex Class
public class test {
public test(ApexPages.StandardController controller) {
list<Attachment> ATT=[SELECT Id FROM Attachment WHERE ParentId = :ApexPages.currentPage().getParameters().get('Id')];
//system.debug('.......'+ATT.size());
For(integer i=0;i<ATT.size();i++){
//System.debug('++++++'+ATT[i]);
PageReference attPage = new PageReference('https://c.cs5.content.force.com/servlet/servlet.FileDownload?file='+ATT[i]);
}
}
}
I am unable to get those results and redirect those results. please help me in that
<apex:page standardController="Account" extensions="test">
<apex:pageBlock >
<apex:form >
<apex:commandButton value="Attachment" action="{!newWindow}"/>
</apex:form>
</apex:pageBlock>
</apex:page>
----------------------------------------------------------------------------------------------------------------------
public class test {
private final account acc;
public Id attId;
public test(ApexPages.StandardController controller) {
this.acc=(account)controller.getrecord();
act = ApexPages.currentPage().getParameters().get('Id');
listAct = [Select Id from Attachment where ParentId =: act];
}
public pagereference newWindow(){
pagereference newTab=new pagereference('/servlet/servlet.FileDownload?file='+listAct[0].Id);
return newTab;
}
Public string act{get; set;}
List<Attachment> listAct = new List<Attachment>();
}
I tried with this model, It wont work for More than 1 attachment. it will openly only one attachment.
i tried using for loop It was throwing this error
Please help me in this, to open multiple attachments using single button
Your for loop (line 14) look like this: