Guest User

Untitled

a guest
Jul 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. trigger relatedrecord on channel__c (before insert, before update) {
  2. Set<Id> caNotetoTLX = new Set<Id>();
  3. Set<Id> newCreatedCAIds = new Set<Id>();
  4. Set<Id> allCustomerIds = new Set<Id>();
  5. Id caseID ;
  6. ID CustId;
  7. if (trigger.isBefore ){
  8. List<channel__c> insertCA = new List<channel__c> ();
  9.  
  10. for(channel__c ca : Trigger.New) {
  11. caseID = ca.case;
  12. newCreatedCAIds.add(caseID);
  13. }
  14. List<case> colletionIds = [SELECT id,AccountId FROM case WHERE Id= :newCreatedCAIds];
  15. List<case> relatedcase= new List<case>();
  16.  
  17. for(case cases: colletionIds){
  18. CustId = cases.AccountId;
  19. allCustomerIds.add(CustId);
  20. }
  21. relatedcase = [Select id, AccountId from case where AccountId= :allCustomerIds AND id <> :caseID ];
  22. List<channel__c> insertNewchannel = new List<channel__c>();
  23.  
  24. for(case ca :relatedcase){
  25. channel__c channel = new channel__c();
  26. channel.Action__c = 'Reviewed Account';
  27. channel.case =ca.id;
  28. insertNewchannel.add(channel);
  29. }
  30. }
  31. }
Add Comment
Please, Sign In to add comment