You need to sign in to do that
Don't have an account?

stop trigger firing anytime source record is edited
i need to stop this trigger firing everytime contact record is edited
here is trigger:
trigger newoppty on contact (after insert, after update) {
list<opportunity> opplist = new list<opportunity>();
for (contact con : trigger.new) {
if(con.Stage__c == 'Lead' && con.contacttype__C =='Seller') {
opportunity newopp = new opportunity ();
newopp.ownerid = con.allocated_user__c;
newopp.name = 'Market Appraisal';
newopp.accountid = con.accountid;
newopp.CurrencyIsoCode = con.currencyisocode;
newopp.stagename = 'Lead';
newopp.recordtypeid = '012250000000Jev';
newopp.contact__c = con.id;
newopp.closedate = Date.today().addDays(7);
newopp.PriceBook2Id = '01s250000005Du6';
opplist.add(newopp);
}
}
try {
insert opplist;
OpportunityLineItem[] lines = new OpportunityLineItem[0];
PricebookEntry[] entry = [SELECT Id, Name, UnitPrice FROM PricebookEntry WHERE Pricebook2Id = '01s250000005Du6' AND name In ('Market Appraisal')];
for(Opportunity record: opplist) {
for (PricebookEntry thisentry : entry)
lines.add(new OpportunityLineItem(PricebookEntryId=thisentry.Id, OpportunityId=record.Id, UnitPrice=thisentry.UnitPrice, Quantity=1));
}
insert lines;
} catch (system.dmlexception e) {
system.debug (e);
}
}
here is trigger:
trigger newoppty on contact (after insert, after update) {
list<opportunity> opplist = new list<opportunity>();
for (contact con : trigger.new) {
if(con.Stage__c == 'Lead' && con.contacttype__C =='Seller') {
opportunity newopp = new opportunity ();
newopp.ownerid = con.allocated_user__c;
newopp.name = 'Market Appraisal';
newopp.accountid = con.accountid;
newopp.CurrencyIsoCode = con.currencyisocode;
newopp.stagename = 'Lead';
newopp.recordtypeid = '012250000000Jev';
newopp.contact__c = con.id;
newopp.closedate = Date.today().addDays(7);
newopp.PriceBook2Id = '01s250000005Du6';
opplist.add(newopp);
}
}
try {
insert opplist;
OpportunityLineItem[] lines = new OpportunityLineItem[0];
PricebookEntry[] entry = [SELECT Id, Name, UnitPrice FROM PricebookEntry WHERE Pricebook2Id = '01s250000005Du6' AND name In ('Market Appraisal')];
for(Opportunity record: opplist) {
for (PricebookEntry thisentry : entry)
lines.add(new OpportunityLineItem(PricebookEntryId=thisentry.Id, OpportunityId=record.Id, UnitPrice=thisentry.UnitPrice, Quantity=1));
}
insert lines;
} catch (system.dmlexception e) {
system.debug (e);
}
}
if it is field,the above one is works
or
if you want to stop contact record,follow below one
just remove after update event in trigger definations...
In that case, just have a trigger on insert and nothing to be done on updates.
Or if you want a new Opportunity every time a certain value is updated on Contact, you need to point that out.
please confirm.