Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger relatedrecord on channel__c (before insert, before update) {
- Set<Id> caNotetoTLX = new Set<Id>();
- Set<Id> newCreatedCAIds = new Set<Id>();
- Set<Id> allCustomerIds = new Set<Id>();
- Id caseID ;
- ID CustId;
- if (trigger.isBefore ){
- List<channel__c> insertCA = new List<channel__c> ();
- for(channel__c ca : Trigger.New) {
- caseID = ca.case;
- newCreatedCAIds.add(caseID);
- }
- List<case> colletionIds = [SELECT id,AccountId FROM case WHERE Id= :newCreatedCAIds];
- List<case> relatedcase= new List<case>();
- for(case cases: colletionIds){
- CustId = cases.AccountId;
- allCustomerIds.add(CustId);
- }
- relatedcase = [Select id, AccountId from case where AccountId= :allCustomerIds AND id <> :caseID ];
- List<channel__c> insertNewchannel = new List<channel__c>();
- for(case ca :relatedcase){
- channel__c channel = new channel__c();
- channel.Action__c = 'Reviewed Account';
- channel.case =ca.id;
- insertNewchannel.add(channel);
- }
- }
- }
Add Comment
Please, Sign In to add comment