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.