• maltesr
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
I have a visualforce page with a controller.
Two parameters are passed: the ID of a custom-object and the ID of an EmailTemplate-Object.
I query the EmailTemplate and want to output the template in a textarea. That works fine.
Unfortunately the merge fields in the EmailTemplate are as they are in the template (e.g.  "{!Custom_Object__c.Field1}").
Is there are simple way to replace those placeholders with the values of the custom-object I get from the passed ID?

I tried this: http://salesforce.stackexchange.com/questions/13/using-apex-to-assemble-html-letterhead-emails/8745#8745
But unfortunately it does not work because I cannot run Database.setSavepoint() at that point. I get the error "DML currently not allowed".

Is there another way to accomplish what I want to do without doing a simple string-replace for all possible Fields of Custom_Object__c?