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

Custom object trigger works in sandbox not in production
Hi,
PLease help.
I have a custom object and a trigger, I see its working in sandbox , with test case coverage of 100% i migrated to production. This trigger is not working.
is there anything to do special for custom triggers?
when a field is updated , oan custom object record is created with a trigger, after record is created I want opportunity object to be updated back.
Here is the code
trigger UpdateRefExist on Customer_Ref_Design__c (after insert) {
List <Opportunity> oppupdate = new List <Opportunity>();
for (Customer_Ref_Design__c ref : Trigger.new){
Opportunity opp = [select Id,RefDesignExist__c from Opportunity where Id = :ref.Oppid__c];
opp.RefDesignExist__c='Y';
oppupdate.add(opp);
}
try {
update oppupdate;
} catch (system.Dmlexception e) {
system.debug (e);
}
}
Thanks
Pallavi
PLease help.
I have a custom object and a trigger, I see its working in sandbox , with test case coverage of 100% i migrated to production. This trigger is not working.
is there anything to do special for custom triggers?
when a field is updated , oan custom object record is created with a trigger, after record is created I want opportunity object to be updated back.
Here is the code
trigger UpdateRefExist on Customer_Ref_Design__c (after insert) {
List <Opportunity> oppupdate = new List <Opportunity>();
for (Customer_Ref_Design__c ref : Trigger.new){
Opportunity opp = [select Id,RefDesignExist__c from Opportunity where Id = :ref.Oppid__c];
opp.RefDesignExist__c='Y';
oppupdate.add(opp);
}
try {
update oppupdate;
} catch (system.Dmlexception e) {
system.debug (e);
}
}
Thanks
Pallavi
2. see the inserted Customer_Ref_Design__c having the opportunity id. If opportunity id is not available then the query will be null.
Let me know if you find any other solution.
1. Check if the trigger is active in PROD.
2. Please bulkify the trigger.
trigger UpdateRefExist on Customer_Ref_Design__c (after insert) {
List <Opportunity> oppupdate = new List <Opportunity>();
set<Id> oppIdSet = new set<Id>();
for (Customer_Ref_Design__c ref : Trigger.new){
if(ref.Oppid__c != null)
oppIdSet.add(ref.Oppid__c);
}
if( Opportunity opp : [select Id,RefDesignExist__c from Opportunity where Id IN:oppIdSet]){
opp.RefDesignExist__c='Y';
oppupdate.add(opp);
}
try {
update oppupdate;
} catch (system.Dmlexception e) {
system.debug (e);
}
}
Thanks,
~KR
~KR