I have a visualforce page that updates a custom object. After the update an email is sent to a related contact. I have to add a checkbox to the page with which the user can choose to send the email or not. Do I have to create a new custom field on the custom object, save the value of the checkbox, and check that field in the trigger that sends the mail, or is there another way (preferably without a new custom field)?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
You could use a static property on the visualforce controller (or another Apex class). The value that is set would be available for the duration of the transaction and thus accessible to the trigger. However, once the transaction has completed you would have no visibility that the user ever checked the box, which, from your description, sounds like it wouldn't be a problem.