3

I have a scenario where I have a custom object to store temporary keys. In my Visualforce email template, I fetch a key and inserts into the email and that works great.

But, I need to be able to set a field called Consumed to true when a key has been taken, to prevent keys from being reused. When trying to update the object using the component controller when opening the template, I get the “Error occurred trying to load the template for preview: DML currently not allowed…” error message.

I have set the allowDML=true in the component and from what I understand the Action functionality cannot be used in a Visualforce email template. Does anybody have an idea of how this can be accomplished?

I guess one option is to create completely new Visualforce pages, replacing the default send mail, but I would be great to avoid that.

  • 4
    Hi JonasU, welcome to SFSE! Please take the time to visit the Help center and read How do I ask a good question. The more details you provide, particularly code you've written, the more likely it is that someone will respond to your question with an answer you'll find helpful. – crmprogdev Jan 11 '17 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.