+ Start a Discussion
gurumikegurumike 

workflow and related lists to send an email alert

I have created two custom objects in a master-detail relationship for managing a company process.  The master (parent) object has some fields including checkboxes for a checklist.  The detail (child) object has a lookup field for a Contact record, and a multi-picklist for the contact's "Role."

 

I want to alert the contacts in the child objects that have certain roles whenever a particular checkbox is checked on the master.

 

The way I've tried going about this is to first create a trigger on the master object that simply updates all of its child objects whenever it is edited.  This is a hacky workaround for getting workflows to run on child objects whenever the master object is edited.  Here's the trigger:

 

trigger touchFulfillmentContacts on Fulfillment__c (after update) {
    Fulfillment_Contact__c[] related = [ select Id, Fulfillment__c, Role__c from Fulfillment_Contact__c
                                         where Fulfillment__c in :Trigger.newMap.keySet() ];
    update related;
}

 

Secondly, I created a workflow on the child object that runs as follows:

 

Evaluation Criteria: When a record is created, or when a record is edited and did not previously meet the rule criteria

 

Rule Criteria (Formula):

 

AND(NOT(ISNULL(Fulfillment__c)), Fulfillment__r.Order_Placed__c, OR(INCLUDES(Role__c, "Manager"), INCLUDES(Role__c, "Sales Engineer"), INCLUDES(Role__c, "Support")))

 

The Order_Placed__c field is one of the checkboxes.  As you can see, I'm trying to select a just few of the roles for this workflow, rather than sending it to all of the contacts in the child records.

 

The action for this workflow is an email alert to the contact on the child object.

 

Unfortunately, this doesn't actually work.  If I have a master record with a checked box, and I create a new child record, I get the email alert.  However, if I repeatedly check and uncheck the field on the master object, I never get the email alert.

 

Has anyone done something like this before?  Can you point me in the right direction?  I'm comfortable with APEX code and I have a few ideas for hacking my way around this; but, I'd prefer to make this work with the standard workflow UI rather than hard-coding the logic elsewhere.

 

Thanks!