You need to sign in to do that
Don't have an account?
kromero
Field Update Trigger for Two Objects
When we send out emails to customers they have the option to opt-out of recieving future emails. If they click on this link then a custom field "unsubscribe date" within our custom object "message statistics" is automatically updated.
Does anyone have suggestions for writing a trigger that once the "unsubscribe date" field within the "message statistics" custom object is filled out then the "opt-out" checkbox within the "contact" object will become checked?
Any suggestions are appreciated as I'm just beginning to learn about Apex code.
Do you have a lookup relationship between the "Message statistics" custom object and Contact object? If so, you can run a query to obtain the Contact record you are looking for, then update the opt-out field to true, or whatever mechanism you use. Are you familiar with SOQL queries at all?
Can you provide some more detail on what the "Message statistics" custom object is, what data it captures, how is it created, etc.?
In that case, you should be able to write your trigger to query the contact record that is the same person related to the "message statistic" record. It would look something like:
where msgStat would be the variable name of a given "message statistic" record that the trigger is executing upon. I am also assuming the API label of the email address field on "message statistic" is Email_address__c