• Dino Kozić
  • NEWBIE
  • 25 Points
  • Member since 2021

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi Friends,
I am getting this error (in the subject) in an Apex class which is called by an Apex Trigger. Not sure whether this SOQL in Apex Class is correct or not. Please help me to fix this:

public static Id AGENCY_RT_ID = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
List<Account> onlyTradBranches = new List<Account>();
List<Id> accountIds = new List<Id>();
accountIds.add(account.Id);
onlyTradBranches = [SELECT Id,Office_Type__c,Status__c,RecordTypeId FROM Account WHERE RecordTypeId =: AGENCY_RT_ID AND ParentId IN : accountIds AND  Office_Type__c =: 'Traditional Branch' AND Status__c IN : ('Active', 'Pending')];

Many thanks in advance.
Vijay
I am getting the following error:
 
QuoteTrigger: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 0Q05D0000007jC3SAI; first error:

ELF_REFERENCE_FROM_TRIGGER, Object (id = 0Q05D0000007jC3) is currently in trigger QuoteTrigger, therefore it cannot recursively update itself: [] Trigger.QuoteTrigger: line 35, column 1

Trigger code is:
 
public static Boolean preventRecursive = true;
    if(preventRecursive){
        preventRecursive = false;
        // Uncheck all latest quotes except for the one manually made latest 
        if(Trigger.isUpdate && Trigger.isBefore){
            if(Trigger.new[0].Latest_quote__c == true) { // proceed only if latest quote is checked
                List<Quote> qtList = [SELECT Id, opportunityId, Latest_quote__c 
                    FROM quote WHERE opportunityId IN :oppIds ORDER BY LastModifiedDate DESC];
                if (qtList.size() > 1) {
                    for(Integer i = 0; i < qtList.size(); i++){ // uncheck all from being latest
                        qtList[i].Latest_quote__c = false;
                    }
                }
                qtList[0].Latest_quote__c = true; // mark only the manually marked as checked
                update qtList;
            }
        }
    }



Line 35 is: update qtList;

 
Hi Friends,
I am getting this error (in the subject) in an Apex class which is called by an Apex Trigger. Not sure whether this SOQL in Apex Class is correct or not. Please help me to fix this:

public static Id AGENCY_RT_ID = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
List<Account> onlyTradBranches = new List<Account>();
List<Id> accountIds = new List<Id>();
accountIds.add(account.Id);
onlyTradBranches = [SELECT Id,Office_Type__c,Status__c,RecordTypeId FROM Account WHERE RecordTypeId =: AGENCY_RT_ID AND ParentId IN : accountIds AND  Office_Type__c =: 'Traditional Branch' AND Status__c IN : ('Active', 'Pending')];

Many thanks in advance.
Vijay