• Pandu@Sfdc
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Relation: Opportunity has related list A and B custom objects. A and B has no relation. 

Criteria: When I insert or Update A records, B records have to create or update

Help: How to I create/update records in B

 

trigger A2B on A (after insert, after update){
set<id> optId = new set<id>();
for(A o : Trigger.new){
optId.add(o.Opportunity__c);
}
map<Id,Opportunity> oppMap = new map<Id,Opportunity>([Select ID from Opportunity where Id IN: optId]);

for (A opt : Trigger.new){
if (oppMap.containskey(opt.Opportunity__c)){
// Opportunity thisOpportunity = optMap.get(opt.Opportunity__c);
}
}
}

 

Thanks,

Pandu