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
kumar palepukumar palepu 

I have to retrieve the all product Name which is corresponding to oppurtunity,,,,i am desiging one email template through visual force.below is code.

Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
Where is below code Kumar ?
 
SantoshChitalkarSantoshChitalkar
Hi Kumar,

get and set opportunity from VF page to controller class. Lets say opportunity Id is 'opptyId', You can get all product Names by using following code - 

List<OpportunityLineItem > lstOLI = [Select Id, OpportunityId, Name From OpportunityLineItem where Id =: opptyId];
List<String> productName = new List<String>();
for(OpportunityLineItem OLI : lstOLI){
     productName.add(OLI.Name);
}

Let me know if this works for you.

Regards,
Santosh Chitalkar
ManojjenaManojjena
Hi ,

From EmailTemplate relatedTo you can get the Opportunity ID .
 
Set<String> productNameSet=new Set<String>();
for(OpportunityLineItem olitem : [SELECT PricebookEntry.Product2.name FROM OpportunityLineItem WHERE Id =: RelatedOppId]){
     productNameSet.add(olitem.PricebookEntry.Product2.name);
}

I think this will help you .