Salesforce Using Flow To Conditionally Update Child Object Fields Automatically

แชร์
ฝัง

ความคิดเห็น • 9

  • @ChristopherJohansen
    @ChristopherJohansen 4 ปีที่แล้ว

    I owe you a beer (or two) for this. Thanks, my man.

    • @Walters954
      @Walters954  4 ปีที่แล้ว

      Glad I could help! You also reminder me of this site I saw a few years back. www.buymeacoffee.com/walters954
      If you're ever in South Florida let me know. There's tons a great spots.

  • @glayceezequiel5449
    @glayceezequiel5449 4 ปีที่แล้ว

    Good job !! Thanks a lot for this video.

    • @Walters954
      @Walters954  4 ปีที่แล้ว

      You are welcome!

  • @laurenceevans3913
    @laurenceevans3913 4 ปีที่แล้ว

    Hi Walters, thanks for the video I hadn't made the connection between process builder and flows yet, which makes much more sense now. I have a question, this flow triggers on record creation - how much more difficult would it be to create a flow that triggers when an existing record meets certain criteria? so Object A exists, and 2 fields get updated on this object to meet certain criteria, then object B will update a field with the current date that the flow ran. Hope this makes sense and thanks again.

  • @IgiveyouNONE
    @IgiveyouNONE 4 ปีที่แล้ว +1

    couldnt you just made a process builder when a record is created or edited on Contact object and than map the fields between Accounts and Contacts? You over-complicated yourself

    • @Walters954
      @Walters954  4 ปีที่แล้ว +3

      You could do this process builder. You would struggle with the actual transferring of the fields part of things because with current setup the PB does not know which child object is active. You would need an additional look on the parent to active child so the new child can get the correct fields. With flow you can do active child search which makes this cleaner in my opinion. I would love to discuss more if you have a simpler idea using PB.

    • @IgiveyouNONE
      @IgiveyouNONE 4 ปีที่แล้ว +1

      @@Walters954 Ah, Sorry. I missunderstand this issue. I forgot that you want to transfer the fields from the old 'active' record to the new one. Not sure if thats possible with PB. I think only way is Flow. You are right!

    • @IgiveyouNONE
      @IgiveyouNONE 4 ปีที่แล้ว

      @@Walters954 I did this with code tho, just for fun :)
      I've struggled a bit since I am not a programmer, hehe.
      ------------------------------------------
      trigger updateRecordsFromOldChildRecords on Objb__c (before insert) {

      //objectA ID'S store the id of the account parent
      List objectAIDs = new List();
      for(Objb__c orderRec : Trigger.new){
      objectAIDs.add(orderRec.ObjA__c);
      }

      //store the id of the child objects where active is true and parent is objectAIDs
      Objb__c activeRecords = [SELECT ID, NAME, Department__c, isActive__c FROM Objb__c where ObjA__c IN: objectAIDs AND IsActive__c = TRUE];


      IF(activeRecords != NULL){
      System.debug('activeRecords' +activeRecords);
      activeRecords.isActive__c =false;
      update activeRecords;
      }


      // loop through new records and copy the value of the field, department from old records
      for (Objb__c orderRec : Trigger.new) {
      orderRec.Department__c= activeRecords.Department__c;
      orderRec.isActive__c = TRUE;
      }

      }