You need to sign in to do that
Don't have an account?
Masie
Trigger not firing- please help
Hello Everyone
Please may I have some help, I have this trigger and it is not firing. Can someone please take a look for me.
trigger updateRates on Rate_Type_del__c (after update) {
Set<Id> RateTypedelids = new Set<Id>();
list <Account> newratelist = new list <Account>();
for(Rate_Type_del__c rate:trigger.new){
RateTypedelids.add(rate.id);
}
List <Account> ratelist =[Select Id, name, Rate_Type__c, Fixed_Credit_Card_Rate__c, Fixed_Debit_Card_Rate__c from Account where Id in:RateTypedelids];
for(Rate_Type_del__c temprate:trigger.new){
for(Account tempacc:ratelist){
if(temprate.Company_del__c == tempacc.id && temprate.RecordType.Name == 'SureSwipe Base Rates' && temprate.Status__c == 'Active'){
{
tempacc.Rate_Type__c = temprate.Rate_Type__c;
tempacc.Fixed_Credit_Card_Rate__c = temprate.Number_Credit_Card_Fee__c;
tempacc.Fixed_Debit_Card_Rate__c = temprate.Number_Debit_Card_Fee__c;
}
}
update newratelist;
}
}
}
Please may I have some help, I have this trigger and it is not firing. Can someone please take a look for me.
trigger updateRates on Rate_Type_del__c (after update) {
Set<Id> RateTypedelids = new Set<Id>();
list <Account> newratelist = new list <Account>();
for(Rate_Type_del__c rate:trigger.new){
RateTypedelids.add(rate.id);
}
List <Account> ratelist =[Select Id, name, Rate_Type__c, Fixed_Credit_Card_Rate__c, Fixed_Debit_Card_Rate__c from Account where Id in:RateTypedelids];
for(Rate_Type_del__c temprate:trigger.new){
for(Account tempacc:ratelist){
if(temprate.Company_del__c == tempacc.id && temprate.RecordType.Name == 'SureSwipe Base Rates' && temprate.Status__c == 'Active'){
{
tempacc.Rate_Type__c = temprate.Rate_Type__c;
tempacc.Fixed_Credit_Card_Rate__c = temprate.Number_Credit_Card_Fee__c;
tempacc.Fixed_Debit_Card_Rate__c = temprate.Number_Debit_Card_Fee__c;
}
}
update newratelist;
}
}
}
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal
All Answers
The first thing I see is that you are trying to run a trigger on an object that has been marked for deletion. You may need to rename your object, and the references to it from Rate_Type_del__c to Rate_Type__c in order to get that trigger to run.
In above code you are creating Set of Id with "Rate_Type_del__c" Object's Id and Querying it on account object i.e
so it should be like :
Replace AccountLookupId with API name of the field and remove Update statement from for loop.
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal
I have done as recommended and its still not working. What I want to do is up[date the account screen with the details on the rate object.
trigger updateRates on Rate_Type_del__c (after update){
Set<Id> RateTypedelids = new Set<Id>();
list <Account> newratelist = new list <Account>();
for(Rate_Type_del__c rate:trigger.new){
RateTypedelids.add(rate.Company_del__c);
}
List <Account> ratelist =[Select Id, name, Rate_Type__c, Fixed_Credit_Card_Rate__c, Fixed_Debit_Card_Rate__c from Account where Id in:RateTypedelids];
for(Rate_Type_del__c temprate:trigger.new){
for(Account tempacc:ratelist){
if(temprate.Company_del__c == tempacc.id &&temprate.RecordType.Name == 'SureSwipe Base Rates' &&temprate.Status__c == 'Active'){
{
tempacc.Rate_Type__c = temprate.Rate_Type__c;
tempacc.Fixed_Credit_Card_Rate__c = temprate.Number_Credit_Card_Fee__c;
tempacc.Fixed_Debit_Card_Rate__c = temprate.Number_Debit_Card_Fee__c;
}
}
}
}
}
The object was deleted then undeleted hence the _del on the name.
Below is the updated code:
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal
If this solves your problem, kindly mark it as the best answer.
Thanks,
Vatsal