Hi Vijay,Here you have logical problem that is you are trying to update same object SalesInfluenceReporting__c so the trigger will execute recursively . you have to prevent recursive trigger exicution or change the logic to before trigger .see the below example:add the below class trigger updateMaster on SalesInfluenceReporting__c (after insert, after update) {
if(updation.isfutureupdate!=true){
Map<Id, String> idMap = new Map<Id, String>();
Boolean matchOnce = false;
for(SalesInfluenceReporting__c obj :trigger.new)
{
idMap.put(obj.Name,obj.MMS_Id__c);
system.debug('********'+idMap);
}
List<Master__c> mList =[Select Id,Opportunity_Id__c from Master__c ];
List<SalesInfluenceReporting__c > ul = new List<SalesInfluenceReporting__c >();
for(SalesInfluenceReporting__c obj :trigger.new)
{
for(Master__c m :mList ){
SalesInfluenceReporting__c rectoUpdate = new SalesInfluenceReporting__c ();
system.debug('+++++++++'+idMap.get(obj.id));
if(matchOnce == false){
if(m.Opportunity_Id__c == idMap.get(obj.id)){
rectoUpdate.Id = obj.id;
rectoUpdate.Master__c = m.id;
matchOnce = true;
ul.add(rectoUpdate );
system.debug('-------'+rectoUpdate );
}
}
break;
}
}
system.debug('@@@@@@@@'+ul);
updation.isfutureupdate=true;
update ul;
}
}
Regards,public class updation
{
public static boolean isfutureupdate=false;
}
3 answers