You need to sign in to do that
Don't have an account?
Timothy Smith
Access CustomObject sibling to Case inside Case Trigger
I am writing an after-insert trigger on the Case object. I am looking to send an email to one of two people depending on a field that is a child of the Account object. A sibling to Case. In my journey I have found that it is not possible to query a sibling (correct me if I'm wrong). So I've decided, once I have the Case, I will take the AccountId and do all of my logic and querys from there.
CustObject_Chld2Acct.fieldname - Child to Account, sibling to Contact
CustObject_Chld2Acct.fieldname - Child to Account, sibling to Contact
List<AggregateResult> AggregateResultList = [SELECT AccountId, Account.Name name, COUNT(Id) co, FROM Case WHERE CreatedDate = LAST_N_DAYS:5 GROUP BY AccountId, Account.Name HAVING COUNT(Id) >= 8]; Set<Id> accIdSet = new Set<Id>(); for(Case c: AggregateResultList) { if(c.AccountId != null) { System.debug(c.AccountId); // Now i have the Account ID, what do I do? //Need to access fields in Account Object (Parent) //Need to access fields in CustObject_Chld2Acct }
Best Answer chosen by Timothy Smith
Abdul Khatri
Please take the following approach, it will help you