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
Stuart GrimshawStuart Grimshaw 

Do Visualforce email templates have access to related_to_id or id?

When using an Apex component from within a Visualforce email template, how do I access the Id of the object the email is related to?

In the Apex controller class I've tried using ApexPages.currentPage().getParameters().get('related_to_id') which works when using the "Send test & verify merge fields" button from the template page, but this doesn't work when the email is sent via an Aproval process.

I've also tried using ApexPages.currentPage().getParameters().get('id') which works in neither!
Best Answer chosen by Stuart Grimshaw
Stuart GrimshawStuart Grimshaw
In the end I added an attribute to the component & passed the Id in via that.

All Answers

Ashish_SFDCAshish_SFDC
Hi Stuart, 


I hope this will help, 

{!CurrentObject__r.RelatedObject__c.FieldName__c} 


Regards,
Ashish
Stuart GrimshawStuart Grimshaw
In the end I added an attribute to the component & passed the Id in via that.
This was selected as the best answer