You need to sign in to do that
Don't have an account?
Davinder Kaur 8
Trigger not working on production.
Hi Can anyone please help me.
I have written a trigger which is working absolutly fine on SANDBOX, but not working on production.
trigger duperror on Sourcing_Tracker__c (before insert) {
for(Sourcing_Tracker__c SrcTrc : trigger.new){
List<Sourcing_Tracker__c> stList=[Select id, CreatedDate, Date_of_Sourcing__c, Date_of_Birth__c, Mobile__c from Sourcing_Tracker__c where Date_of_Birth__c=:SrcTrc.Date_of_Birth__c
And Mobile__c =:SrcTrc.Mobile__c And Date_of_Sourcing__c= LAST_90_DAYS];
if(stList.size()>0 && SrcTrc.Date_of_Birth__c != Null && SrcTrc.Mobile__c != null){
system.debug(stList.size());
SrcTrc.addError('Duplicate Record');
}
}
}
I have written a trigger which is working absolutly fine on SANDBOX, but not working on production.
trigger duperror on Sourcing_Tracker__c (before insert) {
for(Sourcing_Tracker__c SrcTrc : trigger.new){
List<Sourcing_Tracker__c> stList=[Select id, CreatedDate, Date_of_Sourcing__c, Date_of_Birth__c, Mobile__c from Sourcing_Tracker__c where Date_of_Birth__c=:SrcTrc.Date_of_Birth__c
And Mobile__c =:SrcTrc.Mobile__c And Date_of_Sourcing__c= LAST_90_DAYS];
if(stList.size()>0 && SrcTrc.Date_of_Birth__c != Null && SrcTrc.Mobile__c != null){
system.debug(stList.size());
SrcTrc.addError('Duplicate Record');
}
}
}
You mentioned that trigger is not working, does that mean trigger is not firing at all or were you facing any error?
Can you see if the trigger is active in production?
Thanks,
Balaji
LAST_90_DAYS is the date literal used to give a runtime equivalent value for Date.Today().addDays(-90), you can follow the below link for more info on that
http://www.salesforce.com/us/developer/docs/officetoolkit/Content/sforce_api_calls_soql_select_dateformats.htm
Thanks,
Balaji
And deepak it is not at all firing.. N neither giving any errors...
I have a similar problem .. I have a trigger after update in opportunity object to create a case. The trigger is fired but case is not created. Trigger works fine on sandbox but on production it is not creating a case. what could be the problem.??
Also the assignment rules are not firing when case is created on sandbox.
trigger OpportunityAfterTrigger on Opportunity (after update) {
List<Case> caseList = new List<Case>();
for(Opportunity opp: Trigger.new) {
Opportunity oldOpp = Trigger.oldMap.get(opp.Id);
if(opp.ReadyForDSM__c && opp.ReadyForDSM__c!= oldOpp.ReadyForDSM__c)
{
if(opp.What_do_you_need__c== null || opp.What_do_you_need__c== '') {
opp.addError('Please enter What do you need field.');
continue;
}
Case c = new Case();
c.Revision__c = opp.Revision__c;
c.Priority__c = opp.Priority__c;
c.What_do_You_need__c = opp.What_do_you_need__c;
}
}
caseList.add(c);
}
}
if(!caseList.isEmpty()) {
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule = true;
Database.insert(caseList, dmo);
// insert caseList;
}
}