Skip to main content Stream TDX Bengaluru on Salesforce+. Start learning the critical skills you need to build and deploy trusted autonomous agents with Agentforce. Register for free.
Hi 

I have two object A and object B where object b is having  three records in it  i have to do some perform action on object A when object B is to have 4 records in it. how to acheive it , logic 

Thanks

Vijay 
2 respuestas
  1. 6 dic 2015, 6:13
    Hi Vijay ,

    Here I have one question ,Is there any relationship between Obj A & Obj B .Or just you need to to check over all count of object B record ?

    You have to write a trigger in Object A .Inside tthe trigger you can do a aggregate query to get the countof the record in Object B .

    Integer recCountOfObjA=[SELECT count() FROM B];

    However if you want the both object have relationship then logic will very if you want like each record needs to implement same logic .

    Let us know so that we can help !!

    Thanks 

    Manoj

     
  2. 5 dic 2015, 12:25
    Hi Vijay,

    In your after insert trigger use the database.countQuery method to get the count of the dynamic SOQL, and check the no of record in Obect B.

     like below

    integer count= database.countQuery('select count() from B');

    if(count == 4){

    // update records on Obj A

    }

    Regards,

    Amit

     
0/9000