function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
petec@i2isyspetec@i2isys 

Field update on parent case

Hello,

I have a date field in my case records.  If a related case gets that date field populated, is there a way for the Parent case to get it's date field updated with the same date?

 

Thanks,

Pete

agum34agum34

I think you will have to write a trigger to do this until field updates support cross object workflow - http://success.salesforce.com/ideaView?id=08730000000BrrsAAC

 

Let me know if you need a trigger example if you are comfortable with that route.

 

- Alex

petec@i2isyspetec@i2isys

Hi Alex,

I haven't done a trigger yet, so if you could send an example, that would be awesome.

 

Thanks,

Pete

agum34agum34

Here is the salesforce How To on a Trigger - http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_qs_trigger.htm

 

Here is a quick trigger based on what you have requested.  Replace ClosedDate with the actual field you are referring to.  You will also need a test case with 75%+ coverage before deploying to production and you have to write Apex Triggers in a sandbox and deploy them to production using the IDE  or a change set.


trigger CaseTrigger on Case (after insert, after update) {
    List<Case> parentsToUpdate = new List<Case>();
    // Child Cases
    for(Case c : Trigger.new) {
        if (c.ParentID != null) {
            parentsToUpdate.add(new Case(ID=c.ParentID,  ClosedDate=c.ClosedDate));
        }
    }
    if (!parentsToUpdate.isEmpty()) {
        update parentsToUpdate;
    }
}