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
SF DakshendraSF Dakshendra 

I create a custom button for opportunity object when i click on that it generates an attachment and that attachment name will be saved as below format ?

Hi

I create a custom button for opportunity object when i click on that it generates an attachment and that attachment name will be saved as below format 
Format is Account name:listprice__c:time format

listprice__c is product field under opportunity related list ...
for suppose if i have 2 products under opprtinty related list higher amount of listprice__c in these two products will display in attchement format for example i have 2 products under opportunity in these products 1 st product had 25 list price and 2nd product had 40 the attchemat format will be displayed like below.

Account name:40:timeformat

my code is:
   Attinvoice.Name =oppty.account.name+'_'+system.now().format('MM/dd/yyyy')+'.pdf';

 
Siddharth83JainSiddharth83Jain
Hi Dakshendra,

You are missing the product price in the attachment name. You need to loop thru the products related under opportunity and get the max product price selected. Use Aggregate function MAX() here and then add that MAX value to you attachment name.

I hope this makes it clear. Let me know if any issues. 

Please mark this as a best answer if it helps.

Thanks
Siddharth
OSI Consulting.