• Ayyagari Ramesh
  • NEWBIE
  • 40 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 15
    Questions
  • 4
    Replies
I have written an invocable apex class for process builder to update th owner change of accounts and related Opportunity, contracts and quotes on custom object and its working fine. Now i need to bulkify the code. what are the changes required in below code ?
below code :
public class RequestPortalRecords
{
    @InvocableMethod
    public static void ReqChange(List<Request_Portal__c> rp)
    {
        system.debug('entered raghav' +rp);
        Set<Id> accountIds=new Set<Id>();
        Id ownerid;
        list<Account> updateAccOwnerList = new list<Account>();
        list<Opportunity> updateoppList = new list<Opportunity>();
        list<SBQQ__Quote__c> updateqsList = new list<SBQQ__Quote__c>();
        list<contract> updatecrList=new list<contract>();
        
        
        for(Request_Portal__c r : rp)
        {
            accountIds.add(r.Account_Name__c);
            ownerid=r.New_Owner__c;
            system.debug('accountIds'+accountIds+' ownerid'+ ownerid);
            
        }
        
        //updaTE ACCOUNT
        List<Account> accList=[Select id,ownerid from account where id=:accountIds];
        system.debug('accList'+accList.size());
        
        for(Account acc:accList){
            acc.ownerid=ownerid;
            updateAccOwnerList.add(acc);
        }
        
        system.debug('updateAccOwnerList'+updateAccOwnerList.size());
        if(updateAccOwnerList.size()>0){
            update updateAccOwnerList;
        }
        
        //update opportunities
        List<Opportunity> oppList=[Select id,Ownerid,AccountId from Opportunity Where AccountId = :accountIds ];
        system.debug('opplist'+oppList.size());
        
        
        
        for(Opportunity op: opplist){
            op.ownerid=ownerid;
            updateoppList.add(op);
            
        }
        
        system.debug('updateoppList'+updateoppList);  
        
        if(!updateoppList.isEmpty())
            update updateoppList;  
    
    //update Quote
    List<SBQQ__Quote__c> qsList=[Select id,Ownerid from SBQQ__Quote__c where SBQQ__Account__c = :accountIds];
     for(SBQQ__Quote__c qs: qsList){
            qs.ownerid=ownerid;
           updateqsList.add(qs);
            
      }
        system.debug('updateqsList'+updateqsList);  
        
        if(!updateqsList.isEmpty())
            update updateqsList; 
        
        //contract
        List<Contract> crList=[Select id,Ownerid from Contract where AccountId = :accountIds];
     for(Contract qs: crList){
            qs.ownerid=ownerid;
           updatecrList.add(qs);
            
      }
        system.debug('updatecrList'+updatecrList);  
        
        if(!updatecrList.isEmpty())
            update updatecrList;  
    }    
}
Hi All, 

I have written a batch class and the scenerio is to delete the unused reports which are 6 months old. User-added imageI am getting repeated errors, not sure where i am going wrong
Please find the below code  and do let me know if  any changes required to be made.

Batch Class :

global class BatchMassDeleteReports implements Database.Batchable<sObject>{
    

    public Database.QueryLocator start(Database.BatchableContext context)
    {
        return Database.getQueryLocator('Select ID from Report where LastRunDate <= LAST_N_DAYS:180');
    }

    public void execute(Database.BatchableContext context, List<Report> records)
    {
        delete records;
    }
   public void finish(Database.BatchableContext){
        
    }
}  


Also find the schedule class below :


public DeleteReportSchedulerClass() {
    }
    
    global void execute(SchedulableContext sc){
        try{
            //Executing batch class (size:50).
            BatchMassDeleteReports batchApexSchd = new BatchMassDeleteReports();   
            database.executebatch(batchApexSchd, 50);
            
            }catch(exception ex){
             //Catching any exception that occurs.
            System.Debug('There was an error ' + ex.getMessage());
            }
    }




Thanks, 
Ramesh
Hi all,

I have written batch class  which will be sheduled to delete reports which were created 6 months and are not used. I am not sure if this is correct or is there anything required please need suggestion for this.
Global class BatchMassDeleteReports Implements Database.batchable<sobject>{
    
     global Database.QueryLocator start(Database.BatchableContext BC){
        
     return Database.getQueryLocator([SELECT Id from Report where CreatedDate <= LAST_N_DAYS:180 AND LastModifiedDate <= LAST_N_DAYS:180]);
     }
     global  void execute(Database.BatchableContext BC,List<Report> scope){
         list<Report> delReports = (list<Report>)scope;
         if(delReports.CreatedDate <= LAST_N_DAYS:180 && delReports.LastModifiedDate <= LAST_N_DAYS:180)
         {
         delete delReports;
         }   
    }
    global void finish(Database.BatchableContext BC){
        
    }

 } 
connected Application crashes when user login to Application through single sign on, after that Application logo wont appears  instead directed to salesforce login and unable to login using his federation id and password.what may be the reason? 
In VF page i have a picklist field contains 5 picklist values. and for all the 4 picklist values the placholder will be same but for one picklist value the placholder should be different, how to implement this 
As i want to make certain fields read only, and i am facing the issue when i m trying to genarate the pdf. As the values are not coming in pdf output, and when i am removing html-disable = true, the values are coming in pdf
I have written an invocable apex class for process builder to update th owner change of accounts and related Opportunity, contracts and quotes on custom object and its working fine. Now i need to bulkify the code. what are the changes required in below code ?
below code :
public class RequestPortalRecords
{
    @InvocableMethod
    public static void ReqChange(List<Request_Portal__c> rp)
    {
        system.debug('entered raghav' +rp);
        Set<Id> accountIds=new Set<Id>();
        Id ownerid;
        list<Account> updateAccOwnerList = new list<Account>();
        list<Opportunity> updateoppList = new list<Opportunity>();
        list<SBQQ__Quote__c> updateqsList = new list<SBQQ__Quote__c>();
        list<contract> updatecrList=new list<contract>();
        
        
        for(Request_Portal__c r : rp)
        {
            accountIds.add(r.Account_Name__c);
            ownerid=r.New_Owner__c;
            system.debug('accountIds'+accountIds+' ownerid'+ ownerid);
            
        }
        
        //updaTE ACCOUNT
        List<Account> accList=[Select id,ownerid from account where id=:accountIds];
        system.debug('accList'+accList.size());
        
        for(Account acc:accList){
            acc.ownerid=ownerid;
            updateAccOwnerList.add(acc);
        }
        
        system.debug('updateAccOwnerList'+updateAccOwnerList.size());
        if(updateAccOwnerList.size()>0){
            update updateAccOwnerList;
        }
        
        //update opportunities
        List<Opportunity> oppList=[Select id,Ownerid,AccountId from Opportunity Where AccountId = :accountIds ];
        system.debug('opplist'+oppList.size());
        
        
        
        for(Opportunity op: opplist){
            op.ownerid=ownerid;
            updateoppList.add(op);
            
        }
        
        system.debug('updateoppList'+updateoppList);  
        
        if(!updateoppList.isEmpty())
            update updateoppList;  
    
    //update Quote
    List<SBQQ__Quote__c> qsList=[Select id,Ownerid from SBQQ__Quote__c where SBQQ__Account__c = :accountIds];
     for(SBQQ__Quote__c qs: qsList){
            qs.ownerid=ownerid;
           updateqsList.add(qs);
            
      }
        system.debug('updateqsList'+updateqsList);  
        
        if(!updateqsList.isEmpty())
            update updateqsList; 
        
        //contract
        List<Contract> crList=[Select id,Ownerid from Contract where AccountId = :accountIds];
     for(Contract qs: crList){
            qs.ownerid=ownerid;
           updatecrList.add(qs);
            
      }
        system.debug('updatecrList'+updatecrList);  
        
        if(!updatecrList.isEmpty())
            update updatecrList;  
    }    
}
Hi all,

I have written batch class  which will be sheduled to delete reports which were created 6 months and are not used. I am not sure if this is correct or is there anything required please need suggestion for this.
Global class BatchMassDeleteReports Implements Database.batchable<sobject>{
    
     global Database.QueryLocator start(Database.BatchableContext BC){
        
     return Database.getQueryLocator([SELECT Id from Report where CreatedDate <= LAST_N_DAYS:180 AND LastModifiedDate <= LAST_N_DAYS:180]);
     }
     global  void execute(Database.BatchableContext BC,List<Report> scope){
         list<Report> delReports = (list<Report>)scope;
         if(delReports.CreatedDate <= LAST_N_DAYS:180 && delReports.LastModifiedDate <= LAST_N_DAYS:180)
         {
         delete delReports;
         }   
    }
    global void finish(Database.BatchableContext BC){
        
    }

 }