You need to sign in to do that
Don't have an account?
aparna d 1
passing record id to email templates using visualforce components
Hi All,
I am passing record id to email tempalte but am not getting values from visual component to eamil template . Below is my code.
Please help on this. Thanks in advance.
please anyone give me solution on this.
I am passing record id to email tempalte but am not getting values from visual component to eamil template . Below is my code.
Please help on this. Thanks in advance.
Apex class: public class csCompetitiveOppNotification { public Id OppObj{get;set;} public Opportunity opp{get;set;} public string Competitive_Infomation{get;set;} public string SubOppName{get;set;} public csCompetitiveOppNotification(){ try{ Competitive_Infomation=''; SubOppName=''; opp=[Select Id,name,StageName,Competitive__c,Region__c,Territory__c,Ownerid,End_User__c,Accountid,UnitCount_Product__c,Line_Item_PO_Contract_Value__c,Revenue__c from opportunity where id=:OppObj]; List<Opportunity> subOppList= [select name from opportunity where Opportunity_Master__c=:OppObj]; for(Opportunity oppObj:subOppList) { if(SubOppName !=''){ SubOppName=SubOppName+', '; } SubOppName=SubOppName+oppObj.name; } List<Competitive_Infomation__c> comList=[select name from Competitive_Infomation__c where Opportunity__c=:OppObj]; for(Competitive_Infomation__c ciObj:comList){ if(Competitive_Infomation !=''){ Competitive_Infomation=Competitive_Infomation+', '; } Competitive_Infomation=Competitive_Infomation+ciObj.name; } } catch(exception e){ system.debug('test'+e.getMessage()); } } }
VF component: <apex:component controller="csCompetitiveOppNotification" access="global"> <apex:attribute name="Oppid" type="Id" assignTo="{!OppObj}" description="This is the Id of the Opportunity" access="global" /> <apex:outputPanel layout="block"> <html> <body> <table> <tr> <td style="font-weight:bold">Master Opportunity Name:</td> <td>{!opp.Name}</td> </tr> <tr> <td style="font-weight:bold">Account Name:</td> <td>{!opp.Account.Name}</td> </tr> <tr> <td style="font-weight:bold">Enduser:</td> <td>{!opp.End_User__c }</td> </tr> <tr> <td style="font-weight:bold">Competitive Information:</td> <td>{!Competitive_Infomation}</td> </tr> <tr> <td style="font-weight:bold">Sub Opportunities:</td> <td>{!SubOppName }</td> </tr> </table> </body> </html> </apex:outputPanel> </apex:component>
Template <messaging:emailTemplate subject="Competitive Opportunity {!RelatedTo.Inquiry_Number__c} -{!RelatedTo.Name} - {!RelatedTo.Territory__c} {!Relatedto.id}" recipientType="User" relatedToType="Opportunity"> <messaging:htmlEmailBody > <c:cs_Comp_Opp_Notification Oppid="{!Relatedto.Id}" > </c:cs_Comp_Opp_Notification> </messaging:htmlEmailBody> </messaging:emailTemplate>
please anyone give me solution on this.
"Try this one, I used this for getting the record Id of the current record page."
Apex Controller:
Component:
Name: FetchId
Visualforce Email template:
If you find your Solution then mark this as the best answer.
Thank you!
Regards
Suraj Tripathi