I want to know that how to update 2 fields for 2 different objects when the if condition is true in 1 workflow in salesforce?


    if((system.date()=custom_object3__c.field3__c),(custom_object2__c.field2__c=(custom_object2__c.field2__c-1))and(custom_object1__c.field1__c=(custom_object1__c.field1__c-1)),(custom_object2__c.field2__c=custom_object2__c.field2__c)and (custom_object1__c.field1__c=custom_object1__c.field1__c))

if condition is==> if(system.date()==custom_object3__c.field3__c)
if condition is true==> want to perform:


if condition is false==> want to perform:


It is not possible to do this through configuration, e.g., using workflow or process builder as they are limited to one object per rule/process. The logic here is that you cannot say that you can run a field update A for an account and a field update B for a contact due to the fact there are either no relationships between the objects or that there are more than a one to one relationship leading to an inability to decide which record to update.

  • I want to update the fields of B and C depending on condition that A's date field has the current date. C is the master and B is it's child, and A is Child of B. Can you suggest what to do with steps in detail? – sugandhi May 8 '15 at 5:33

It is not possible through one Workflow rule. For Cross-object field updates for a workflow, a change to a detail record can update a field on the related master record only. As in this case a Workflow on "custom_object3__c" will update a field on it's Master record i.e. "custom_object2__c". To achieve field updates on both custom_object3__c and custom_object2__c you can create two workflows and two field updates (one on custom_object3__c and other on custom_object2__c). The execution of field update on custom_object2__c should trigger the Workflow on "custom_object2__c", which will update the field on "custom_object1__c".

You can also use Apex Trigger to achieve the same result.

for info on Cross Object field updates: https://help.salesforce.com/apex/HTViewHelpDoc?id=workflow_field_update_considerations.htm

  • thanks for answering. Can you tell me how the field update on "custom_object2__c" field will trigger the workflow on "custom_object2__c", and updating field of "custom_object1__c". – sugandhi May 8 '15 at 7:21
  • The workflow on "custom_object2__c" needs to execute/ get triggered as a result of the workflow field update on "custom_object2__3". Therefore the field-update on "custom_object2__c" needs to be the Workflow Evaluation Criteria. A simpler way would be to set the Workflow on "custom_object2__c" to execute everytime the record is edited. But this will result in the Workflow getting fired unnecessarily. So set the workflow to fire only when Formula evaluates to true, and in the Formula check if the field (field referred in the field update on custom_object3__c) is getting is updated. – Shashank Shastri May 8 '15 at 13:02
  • This approach has it's limitations. There is no way to identify if the field on "custom_object2__c" is getting updated due to a workflow. Thus the workflow in "custom_object2__c" will get fired if the record is updated manually and it meets the workflow evaluation criteria. – Shashank Shastri May 8 '15 at 13:05

Workflow won't allow for manipulation of child records (i think). But you could use Process builder to do this, basially first you set conditions for parent record to fire, then set conditions as to what child records should get updated.

You could go deeper in relationships by using another process that is being triggered when the previous one starts, and that way update another level of child records.


The only way that you can guarantee that this is done would be to put your logic in a trigger. Your trigger would be on the top level object that you wish to update the other two fields from. You will need to find the objects in your trigger that you wish to update and you can add them to a List<SObject> and update them both simultaneously. See below pseudo based on your supplied pseudo...

trigger CustomObjectTrigger on Custom_Object_1__c( before insert, before update, after insert, after update, before delete, after delete ){

        Map<Id, SObject> newMap = Trigger.newMap;

        List<SObject> object2List = [ SELECT Id, Custom_Object_1_MD_or_Lookup__c, some_other_fields__c FROM Custom_Object_2__c WHERE Custom_Object_1_MD_or_Lookup__c IN: newMap.keySet() ];
        List<SObject> object3List = [ SELECT Id, Custom_Object_1_MD_or_Lookup__c, some_other_fields__c FROM Custom_Object_3__c WHERE Custom_Object_1_MD_or_Lookup__c IN: newMap.keySet() ];

        Map<String, List<SObject>> obj2MapByObj1Id = new Map<String, List<SObject>>();
        Map<String, List<SObject>> obj3MapByObj1Id = new Map<String, List<SObject>>();

        // organize all sibling obj 2 by the parent for quick access
        for( SObject record : object2List ){
            String objParentId = String.valueOf( record.get( 'Custom_Object_1_MD_or_Lookup__c' ) );
            List<SObject> siblings = obj2MapByObj1Id.containsKey( objParentId ) ? obj2MapByObj1Id.get( objParentId ) : new List<SObject>();

            siblings.add( record );
            obj2MapByObj1Id.put( objParentId, siblings );

        // organize all sibling obj 3 by the parent for quick access
        for( SObject record : object3List ){
            String objParentId = String.valueOf( record.get( 'Custom_Object_1_MD_or_Lookup__c' ) );
            List<SObject> siblings = obj3MapByObj1Id.containsKey( objParentId ) ? obj3MapByObj1Id.get( objParentId ) : new List<SObject>();

            siblings.add( record );
            obj3MapByObj1Id.put( objParentId, siblings );

        List<SObject> updateList = new List<SObject>();
        // iterate in the trigger records and create an update list
        for( Custom_Object_1__c record : Trigger.new ){

            List<SObject> obj2Children = obj2MapByObj1Id.containsKey( record.Id ) ? obj2MapByObj1Id.get( record.Id ) : new List<SObject>();
            List<SObject> obj3Children = obj3MapByObj1Id.containsKey( record.Id ) ? obj3MapByObj1Id.get( record.Id ) : new List<SObject>();

            if( some logic here ){

                ... update obj2 child(ren)
                ... update obj3 chid(ren)

                updateList.addAll( obj2Children );  // make sure they get in the update list
                updateList.addAll( obj3Children );  // make sure they get in the update list

        // update as necessary
        if( !updateList.isEmpty() ){
            Database.SaveResult[] mResult = Database.update( updateList, false ); // using false here allows you to update what can be updated and the rest will return an error in the SaveResult

            for( Database.SaveResult result : mResult ){

                if( !result.isSuccess() ){
                    // do some stuff with your errors


This of course is a very generic written solution given very generic condition but i think you get the idea.

We use the List<SObject> here since we can save the generic objects with a single save and they can be different declared types. The generic List<SObject> holds some power in that.

Some things to note

You will be limited to the number of different types of SObject that can exist within the same list. I would suggest to keep the different SObjects down to 2 or 3 to avoid getting errors when saving due to too many types in your List<SObject>

If not updating additionally the object that you are triggering on, I would also suggest that you check the trigger context that you are in by using:

if( Trigger.isAfter && Trigger.isUpdate ){
    .... your logic

if you are going to update the current object in your trigger - you should use before update

if( Trigger.isBefore && Trigger.isUpdate ){
    .... your logic

Additional Links

HERE is a good blog post that outlines this behavior that would be helpful as another example.


If there is no relationship between the objects then this is not possible to achieve. The workflow can only update the same record or the Master record. no other record can be manipulated using just workflow.


I believe you can create two separate field updates and assign them to the same workflow rule.

  • Depends completely on how these 2 objects are related to each other. – Robin De Bondt May 7 '15 at 9:48
  • @patlatus My custom_object1__c is the master and custom_object2__c is it's child. Similarly, custom_object2__c is the master and custom_object3__c is it's child. I am adding workflow on custom_object3__c ,but action doesn't allow me to update the field of custom_object1__c as it's only showing the custom_object2__c in the picklist. Please help. – sugandhi May 7 '15 at 18:12
  • @RobinDeBondt wht's the another way? – sugandhi May 7 '15 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.