• Ramya Balakrishnan
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 7
    Replies
Hello All
I have scenario where i need to calculate two fields Data_quality_score and Data_quality_desc on account object when a new account is created or updated based on other field values.
I have the following trigger handler class. In which i have created one method called PopulateDataQualityScoreFields to calculate the data quality score field values before saving the record. 

public class AccountTriggerHandler extends TriggerFrameWork {
    private List<Account> newAccountList;
    private Map<Id, Account> oldAccountMap;

    public AccountTriggerHandler() {
        this.newAccountList = (List<Account>) Trigger.new;
        this.oldAccountMap = (Map<Id,Account>) Trigger.oldmap; 
    }
    public override void beforeInsert() {
        for(Account account : newAccountList) {
            if(account.Firm_Revenue_Last_Known__c != null) {
                account.Firm_Revenue__c = account.Firm_Revenue_Last_Known__c;
            }
            if(account.Firm_Revenue_Last_Known__c == null && account.Firm_Revenue_2_Years_Ago__c != null) {
                account.Firm_Revenue__c = account.Firm_Revenue_2_Years_Ago__c;
            }
            if(account.Firm_Revenue_Last_Known__c == null && account.Firm_Revenue_2_Years_Ago__c == null
                    && account.Firm_Revenue_3_Years_Ago__c != null) {
                account.Firm_Revenue__c = account.Firm_Revenue_3_Years_Ago__c;
            }
            if(account.Lead_Type__c == 'Household') {
                account.recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Household').getRecordTypeId();
            }
            if(account.Lead_Type__c == 'Firm') {
                account.recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Firm').getRecordTypeId();
            }
        }
        PopulateDataQualityScoreFields();
    }
    public override void beforeUpdate() {
        for(Account account : newAccountList) {
            if(account.Firm_Revenue_Last_Known__c != null && account.Firm_Revenue_Last_Known__c != oldAccountMap.get(account.Id).Firm_Revenue_Last_Known__c) {
                account.Firm_Revenue__c = account.Firm_Revenue_Last_Known__c;
            }
            if(account.Firm_Revenue_Last_Known__c == null && account.Firm_Revenue_2_Years_Ago__c != null
                    && account.Firm_Revenue_2_Years_Ago__c != oldAccountMap.get(account.Id).Firm_Revenue_2_Years_Ago__c) {
                account.Firm_Revenue__c = account.Firm_Revenue_2_Years_Ago__c;
            }
            if(account.Firm_Revenue_Last_Known__c == null && account.Firm_Revenue_2_Years_Ago__c == null
                    && account.Firm_Revenue_3_Years_Ago__c != null
                    && account.Firm_Revenue_3_Years_Ago__c != oldAccountMap.get(account.Id).Firm_Revenue_3_Years_Ago__c) {
                account.Firm_Revenue__c = account.Firm_Revenue_3_Years_Ago__c;
            }
        }
        PopulateDataQualityScoreFields();
    }

 public void PopulateDataQualityScoreFields( )
   {
    String DQDescription;
    Integer DQScore;
    for(Account account : newAccountList) {
    if (account.Lead_Type__c == 'Firm') {
        if(account.Data_Quality_Score__c <> 100){
          DQDescription = 'Missing: ';
          if(account.Owner.Profile.Name == null || account.Owner.Profile.Name == 'Integration Profile'){
             DQDescription = DQDescription + 'Owner,';
             DQScore = DQScore + 10;
          }
          if(account.AuMine_External_Id__c <> null && (account.Regional_Firms_Broker__c == null ||
             account.Regional_Firms_Broker__c == 'Integration Profile')){
             DQDescription = DQDescription + 'RF Broker';
             DQScore = DQScore + 5;
          } 
          if(account.Related_Contacts__c == null || account.isVictim__c == True){
            DQDescription = DQDescription + 'Contact, ';
            DQScore = DQScore + 15;
          }
          if(account.Phone_MDM__c == null || account.Phone_MDM__c.length() !=10){
            DQDescription = DQDescription + 'Phone, ';
            DQScore = DQScore + 15;
          } 
          if(account.Firm_Revenue__c == null || account.Firm_Revenue__c == 0){
            DQDescription = DQDescription + 'Firm Revenue, ';
            DQScore = DQScore + 15;
          } 
          if(account.AuMine_External_Id__c <> null && account.Tax_ID__c == null){
             DQDescription = DQDescription + 'Tax ID, ';
             DQScore = DQScore + 5;
          }
          if(account.hasBusinessAddress__c == null || account.hasBusinessAddress__c == 0){
            DQDescription = DQDescription + 'Biz Address,';
            DQScore = DQScore + 15;
          } 
          if(account.Last_Known_PL_Expiration_Date__c == null){
            DQDescription = DQDescription + 'Last Known PL Expiration Date, ';
            DQScore = DQScore + 10;
          }
          if(account.Missing_Renewal_Opportunities__c > 0){
            DQDescription = DQDescription + account.Missing_Renewal_Opportunities__c + 'Renewal Opportunity';
            DQScore = DQScore + 10;
          }
          account.Data_Quality_Score__c = DQScore ; 
          account.Data_Quality_Description__c = DQDescription;
                                                    
       }
    } 
   } 
      
   } 
    
}

But it is not updating. The list newAccountList doesnt have any value in the PopulateDataQualityScoreFields method in the debug log. So the loop exits without calculating. I dont see the constructor statements executed in the debug log. Whats wrong in the code ? Can anybody help with this ?
Which is the best way to achieve this Triger or Flow ?
Thanks All.

Thnaks
Ramya Balakrishnan
Hello All

   I am new salesforce admin/developer. I have a requirement to create a new field(# of Active policy) in Account object which calculate the total no of active policy associated in the account. Whenever a new policy is added or expired, the new field(# of Active policy) in account object  is calculated. I am calculating this in Policy Trigger hander class. It is working fine whenever the policy status is changed or added. Now i need to calculate this field value for all the accounts with existing policy. What is the best way to achieve this?  Dataloader to update field in Policy object ? or Flow builder?

Please suggest ideas.

Thanks
Ramya Balakrishnan
I have a requirement for creating Data table LWC component. the component look like the following format.User-added image
I have written the following  query for getting data from salesforce for this table.

SELECT  Product__c ,COUNT(Quantity__c), 
    SUM(CASE
 WHEN invoice_date = CALENDAR_YEAR(system.today()) THEN 
             Total_Price__c
             ELSE 0 
           END) AS "This year Sales" ,
   SUM( CASE
 WHEN invoice_date = CALENDAR_YEAR(system.today()) - 1 THEN 
             Total_Price__c
             ELSE 0 
           END) AS "Last year Sales" 
 FROM Invoice_Lines__c GROUP BY Invoice_Lines__c.Product__c

I am getting 'Unknown error query parsing'  error. If i remove the case statements , the query runs without any error. i am not able to figure out the issue with the case statements.
Can anybody suggest how to solve this error or is there any other way i can modify the query? i need a single query to pass the records to the datatable component.

Thanks
Ramya Balakrishnan
Hi all

  I have two users A and B assigned into the same profile. I need to show different picklist values for different user like VAL1,VAL2 ,VAL 3 for  user A and VAL 4 ,VAL5 for user B. 
Can anybody suggest how to achieve this ? 
Hi all

The following error is showing while trying to create lightning data table component in Visual studio code. Please suggest how to resolve this. Thanks.
<template>
    <h1 style="height: 30px;font-size:14px;background-color:#F4F4F4;padding-left:10px; text-align:left;font-weight: bold;">
        Sales(Year over Year)
    </h1>
 <div style="height: 300px;">

      <lightning-datatable
                key-field="id"
                data={data}
                show-row-number-column
                row-number-offset={rowOffset}
                suppress-bottom-bar
                columns={columns}>
        </lightning-datatable>
    </div>
</template>

User-added image
Hi all  
I have the following class which is called in Flow action when creating events. I am getting the following error when i try to create event.

We can't save this record because the “Type” process failed. Give your Salesforce admin these details. An Apex error occurred: System.LimitException: Too many query rows: 50001 Error ID: 563784318-263669 (-505665031)ccurred: System.LimitException: Too many query rows: 50001 Error ID: 563784318-263669 (-505665031)


The class


public class UpdateNo_ofInterviewsWithTotalActivities {

    // Do not remove this variable as this is used in the trigger to avoid loop
    public static Boolean isUpdatingNumberOfInterviews = false;

  
    /* @description : This method updates opportunity's Number_of_Interviews__c field based on the
    * opportunity's Event subject
    * @param : events list of Event derived from Process builder
    */
    @InvocableMethod public static void updateOppField(List<Event> events) {
        try {
            Set<Id> oppIdsRelatedToEvents = new Set<Id>();

            for (Event evnt : events) {
                String sub = evnt.Subject;
                if (sub != null && (sub.containsIgnoreCase('Interview') || sub.containsIgnoreCase('intvw') || sub.containsIgnoreCase('screen'))) {
                    System.debug('Event Subject is: ' + sub);
                    if (evnt.WhatId != null || evnt.WhatId != '') {
                        oppIdsRelatedToEvents.add(evnt.WhatId);
                    }
                }
            }
            System.debug('oppIdsRelatedToEvents' + oppIdsRelatedToEvents);

            List<Opportunity> oppsList = [SELECT Id, Name, Number_of_Interviews__c FROM Opportunity WHERE Id In:oppIdsRelatedToEvents];
            System.debug('Opportunities with the Event subjects that contains Interview : ' + oppsList);

            List<Event> eventsList = [SELECT Id, WhatId, Subject FROM Event WHERE WhatId In:oppIdsRelatedToEvents];
            System.debug('Events that are related to Opportunities : ' + eventsList);

            Map<Id, Set<Id>> eventOppsMap = new Map<Id, Set<Id>>();
            if (eventsList != null) {
                for (Event e : eventsList) {
                    if (e != null && e.WhatId != null) {
                        String sub = e.Subject;
                        if (sub != null && sub.containsIgnoreCase('Interview') || sub.containsIgnoreCase('intvw') || sub.containsIgnoreCase('screen')) {
                            if (!eventOppsMap.containsKey(e.WhatId)) {
                                Set<Id> eventsIds = new Set<Id>();
                                eventsIds.add(e.Id);
                                eventOppsMap.put(e.WhatId, eventsIds);
                            } else {
                                Set<Id> eventsIds = eventOppsMap.get(e.WhatId);
                                eventsIds.add(e.Id);
                            }
                        }
                    }
                }
            }
            System.debug('Events with Opps map : ' + eventOppsMap);
            List<Opportunity> oppsTobeUpdated = new List<Opportunity>();
            if (oppsList != null) {
                for (Opportunity opp : oppsList) {
                    Set<Id> oppEventIds = eventOppsMap.get(opp.Id);
                    // Do not remove this variable as this is used in the trigger to avoid loop
                    if (oppEventIds.size() > 0)
                        isUpdatingNumberOfInterviews = true;
                    opp.Number_of_Interviews__c = oppEventIds.size();
                    System.debug('Number of Interviews : ' + opp.Number_of_Interviews__c);
                    oppsTobeUpdated.add(opp);
                }
                try {
                    update oppsTobeUpdated;
                }
                catch(DmlException dmle) {
                    System.debug(dmle);
                    System.debug(dmle.getMessage());
                    DBUtils dbUtil = new DBUtils();
                    dbUtil.handleException('Updating opportunities in process builder', dmle.getMessage(), dmle.getLineNumber());
                }
                System.debug('Opps to be updated in the Update No.of Activities class are : ' + oppsTobeUpdated);
            }
        }
        catch(Exception e) {
            system.debug(e);
            system.debug('Exception occurred when updating the events : ' + e.getMessage());
        }
    }
}


In sandbox it is working. In production we are getting this error. Do I need to use Batch Apex? How to implement batch apex in this?
I have a requirement in which client wants to see the below info in each account record detail page. we are thinking of Data table LWC component since it is not possible with reports.User-added image
Years will be CY2022 ,CY2021 and instead of total i need to display Diff.
.What is the best way to achieve this ? 
Hi all 

   I have a visualforce page form created in which i need to display picklist values as shown in attached file.Certificate and Strength picklist needs to created in visual force page.

Those picklist values are from the contact objects. I am not able to use Apex inputFields since it is not editable when i open this VF page through site.So I am using inputText to display other text fields.Can anybody help how to create this type of picklist in visualforce page.

Thanks
Ramya Balakrishnan
Hi all

I have this following method which is sending email.It was working fine till yesterday. I just changed the message in email template today .when i try to test it showing STORAGE_LIMIT_EXCEEDED exception. I tried with different emails also. It is not working. Can anybody give solution to this.

private void sendEmail(){
        String EmailBody,Subject;
        Contact prjLead;
        String prjLeadEmail;
        List<EmailTemplate> emailTemplateIds = new List<EmailTemplate>();
      
         //Fetch Email Template Id to be send to Candidate and Project Lead 
         
         If(removeProjInterest = True) 
             emailTemplateIds = [SELECT Id,Subject,Body
                                                 FROM EmailTemplate
                                                 WHERE DeveloperName='Request_To_Leave_Project' LIMIT 1] ;
                                                
                                                 
         else                                                   
              emailTemplateIds = [SELECT Id,Subject,Body
                                                 FROM EmailTemplate
                                                 WHERE DeveloperName='Project_Join_Request' LIMIT 1];                                     
        
        //Fetch the Project Lead Details
        If(selPrjLeadId != null){
             prjLead = [SELECT Id,FirstName,Name,Email 
                                         FROM Contact 
                                         WHERE id=:selPrjLeadId 
                                         LIMIT 1];
             projectLead = prjLead.Name; // Value referred in VF Page
             prjLeadEmail = prjLead.Email;
             prjLeadOrManager = 'project lead';  //Value referred in VF Page
        } else{
            //If Project Lead not defined, Email fetched from Custom Metadata settings
            MR_Project_List_Setting__mdt PrjListMetaData = [SELECT PMO_Email__c,PMO_Name__c 
                                                                  FROM MR_Project_List_Setting__mdt
                                                                  WHERE DeveloperName  ='PMO_Details' LIMIT 1];
            projectLead = PrjListMetaData.PMO_Name__c;
            prjLeadEmail = PrjListMetaData.PMO_Email__c;
            prjLeadOrManager = 'project manager';      //Value referred in VF Page
        }
        
        //New instance of a single email message sent to candidate
       Messaging.SingleEmailMessage emailCand = new Messaging.SingleEmailMessage();
       List<String> canEmailList = new List<String>();
       List<String> prjLeadEmailList = new List<String>();
        
        //Fetch the Candidate details
       If(contactId != null){
             
              EmailBody = emailTemplateIds.get(0).Body;
           If(EmailBody !=null){
               EmailBody = EmailBody.replace('Candidate',candFirstName);
               EmailBody = EmailBody.replace('project', selPrjName);                        
               EmailBody = EmailBody.replace('lead',projectLead);
               EmailBody = EmailBody.replace('plOrpm', prjLeadOrManager); 
               EmailBody = EmailBody.replace('LeadEmail',prjLeadEmail);  
               if(removeProjInterest = True) 
               {
               EmailBody = EmailBody.replace('CandEmail',candEmail);
               }
            
           }
              canEmailList.add(candEmail);
              emailCand.toaddresses =canEmailList;
              prjLeadEmailList.add(prjLeadEmail);
              emailCand.ccaddresses = prjLeadEmailList;
              emailCand.setTargetObjectId(contactId);
               Subject = emailTemplateIds[0].Subject;
               emailCand.setSubject(Subject); 
                emailCand.setPlainTextBody(EmailBody);
              try{            
                  Messaging.sendEmail(new Messaging.SingleEmailMessage[] { emailCand });
                  system.debug('Candidate & Project Lead Email Sent Successfully');
              }  catch(exception e){
                      system.debug('Error email');
                      apexpages.addmessage(new apexpages.message(apexpages.severity.error,e.getMessage()));
                      system.debug('Error Sending Candidate and Project Lead email '+e.getMessage());
               }
        
        }
            
 }
    

15:48:46.0 (588298556)|EXCEPTION_THROWN|[338]|System.EmailException: SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: [] 15:48:46.0 (588751848)|HEAP_ALLOCATE|[338]|Bytes:111 15:48:46.0 (588837018)|VARIABLE_SCOPE_BEGIN|[340]|e|Exception|true|false 15:48:46.0 (588947495)|VARIABLE_ASSIGNMENT|[340]|e|"common.apex.methods.MessagingStaticMethods$EmailExecutionException: SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: []"|0xf2b3972 15:48:46.0 (588958756)|STATEMENT_EXECUTE|[340] 15:48:46.0 (588961850)|STATEMENT_EXECUTE|[341] 15:48:46.0 (588991982)|HEAP_ALLOCATE|[341]|Bytes:11 15:48:46.0 (589045155)|USER_DEBUG|[341]|DEBUG|Error email 15:48:46.0 (589057755)|STATEMENT_EXECUTE|[342] 15:48:46.0 (589254533)|HEAP_ALLOCATE|[342]|Bytes:107 15:48:46.0 (589428174)|VF_PAGE_MESSAGE|SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: [] 15:48:46.0 (589439526)|STATEMENT_EXECUTE|[343] 15:48:46.0 (589451863)|HEAP_ALLOCATE|[343]|Bytes:47 15:48:46.0 (589472850)|HEAP_ALLOCATE|[343]|Bytes:107 15:48:46.0 (589489892)|HEAP_ALLOCATE|[343]|Bytes:154 15:48:46.0 (589502124)|USER_DEBUG|[343]|DEBUG|Error Sending Candidate and Project Lead email SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: [] 15:48:46.0 (589525677)|METHOD_EXIT|[694]|01p3u00000ILbF5|ProjectsList.sendEmail()
Hi all
I would like to call a visual page(AddCertifications) from another visual page(ProfileUpadate) in button click. But nothing is coming when i click the button.This is my code
PageReference p = new PageReference('/apex/AddCertifications?id='+cid);
p.setRedirect(true);
return p;

The requirement is when i click the upload button in ProfileUpadate page , the AddCertifications page will open for uploading file.Both the pages extends different controllor. How to achieve this one? 
Hello All
I have scenario where i need to calculate two fields Data_quality_score and Data_quality_desc on account object when a new account is created or updated based on other field values.
I have the following trigger handler class. In which i have created one method called PopulateDataQualityScoreFields to calculate the data quality score field values before saving the record. 

public class AccountTriggerHandler extends TriggerFrameWork {
    private List<Account> newAccountList;
    private Map<Id, Account> oldAccountMap;

    public AccountTriggerHandler() {
        this.newAccountList = (List<Account>) Trigger.new;
        this.oldAccountMap = (Map<Id,Account>) Trigger.oldmap; 
    }
    public override void beforeInsert() {
        for(Account account : newAccountList) {
            if(account.Firm_Revenue_Last_Known__c != null) {
                account.Firm_Revenue__c = account.Firm_Revenue_Last_Known__c;
            }
            if(account.Firm_Revenue_Last_Known__c == null && account.Firm_Revenue_2_Years_Ago__c != null) {
                account.Firm_Revenue__c = account.Firm_Revenue_2_Years_Ago__c;
            }
            if(account.Firm_Revenue_Last_Known__c == null && account.Firm_Revenue_2_Years_Ago__c == null
                    && account.Firm_Revenue_3_Years_Ago__c != null) {
                account.Firm_Revenue__c = account.Firm_Revenue_3_Years_Ago__c;
            }
            if(account.Lead_Type__c == 'Household') {
                account.recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Household').getRecordTypeId();
            }
            if(account.Lead_Type__c == 'Firm') {
                account.recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Firm').getRecordTypeId();
            }
        }
        PopulateDataQualityScoreFields();
    }
    public override void beforeUpdate() {
        for(Account account : newAccountList) {
            if(account.Firm_Revenue_Last_Known__c != null && account.Firm_Revenue_Last_Known__c != oldAccountMap.get(account.Id).Firm_Revenue_Last_Known__c) {
                account.Firm_Revenue__c = account.Firm_Revenue_Last_Known__c;
            }
            if(account.Firm_Revenue_Last_Known__c == null && account.Firm_Revenue_2_Years_Ago__c != null
                    && account.Firm_Revenue_2_Years_Ago__c != oldAccountMap.get(account.Id).Firm_Revenue_2_Years_Ago__c) {
                account.Firm_Revenue__c = account.Firm_Revenue_2_Years_Ago__c;
            }
            if(account.Firm_Revenue_Last_Known__c == null && account.Firm_Revenue_2_Years_Ago__c == null
                    && account.Firm_Revenue_3_Years_Ago__c != null
                    && account.Firm_Revenue_3_Years_Ago__c != oldAccountMap.get(account.Id).Firm_Revenue_3_Years_Ago__c) {
                account.Firm_Revenue__c = account.Firm_Revenue_3_Years_Ago__c;
            }
        }
        PopulateDataQualityScoreFields();
    }

 public void PopulateDataQualityScoreFields( )
   {
    String DQDescription;
    Integer DQScore;
    for(Account account : newAccountList) {
    if (account.Lead_Type__c == 'Firm') {
        if(account.Data_Quality_Score__c <> 100){
          DQDescription = 'Missing: ';
          if(account.Owner.Profile.Name == null || account.Owner.Profile.Name == 'Integration Profile'){
             DQDescription = DQDescription + 'Owner,';
             DQScore = DQScore + 10;
          }
          if(account.AuMine_External_Id__c <> null && (account.Regional_Firms_Broker__c == null ||
             account.Regional_Firms_Broker__c == 'Integration Profile')){
             DQDescription = DQDescription + 'RF Broker';
             DQScore = DQScore + 5;
          } 
          if(account.Related_Contacts__c == null || account.isVictim__c == True){
            DQDescription = DQDescription + 'Contact, ';
            DQScore = DQScore + 15;
          }
          if(account.Phone_MDM__c == null || account.Phone_MDM__c.length() !=10){
            DQDescription = DQDescription + 'Phone, ';
            DQScore = DQScore + 15;
          } 
          if(account.Firm_Revenue__c == null || account.Firm_Revenue__c == 0){
            DQDescription = DQDescription + 'Firm Revenue, ';
            DQScore = DQScore + 15;
          } 
          if(account.AuMine_External_Id__c <> null && account.Tax_ID__c == null){
             DQDescription = DQDescription + 'Tax ID, ';
             DQScore = DQScore + 5;
          }
          if(account.hasBusinessAddress__c == null || account.hasBusinessAddress__c == 0){
            DQDescription = DQDescription + 'Biz Address,';
            DQScore = DQScore + 15;
          } 
          if(account.Last_Known_PL_Expiration_Date__c == null){
            DQDescription = DQDescription + 'Last Known PL Expiration Date, ';
            DQScore = DQScore + 10;
          }
          if(account.Missing_Renewal_Opportunities__c > 0){
            DQDescription = DQDescription + account.Missing_Renewal_Opportunities__c + 'Renewal Opportunity';
            DQScore = DQScore + 10;
          }
          account.Data_Quality_Score__c = DQScore ; 
          account.Data_Quality_Description__c = DQDescription;
                                                    
       }
    } 
   } 
      
   } 
    
}

But it is not updating. The list newAccountList doesnt have any value in the PopulateDataQualityScoreFields method in the debug log. So the loop exits without calculating. I dont see the constructor statements executed in the debug log. Whats wrong in the code ? Can anybody help with this ?
Which is the best way to achieve this Triger or Flow ?
Thanks All.

Thnaks
Ramya Balakrishnan
I have a requirement for creating Data table LWC component. the component look like the following format.User-added image
I have written the following  query for getting data from salesforce for this table.

SELECT  Product__c ,COUNT(Quantity__c), 
    SUM(CASE
 WHEN invoice_date = CALENDAR_YEAR(system.today()) THEN 
             Total_Price__c
             ELSE 0 
           END) AS "This year Sales" ,
   SUM( CASE
 WHEN invoice_date = CALENDAR_YEAR(system.today()) - 1 THEN 
             Total_Price__c
             ELSE 0 
           END) AS "Last year Sales" 
 FROM Invoice_Lines__c GROUP BY Invoice_Lines__c.Product__c

I am getting 'Unknown error query parsing'  error. If i remove the case statements , the query runs without any error. i am not able to figure out the issue with the case statements.
Can anybody suggest how to solve this error or is there any other way i can modify the query? i need a single query to pass the records to the datatable component.

Thanks
Ramya Balakrishnan
Hi all

The following error is showing while trying to create lightning data table component in Visual studio code. Please suggest how to resolve this. Thanks.
<template>
    <h1 style="height: 30px;font-size:14px;background-color:#F4F4F4;padding-left:10px; text-align:left;font-weight: bold;">
        Sales(Year over Year)
    </h1>
 <div style="height: 300px;">

      <lightning-datatable
                key-field="id"
                data={data}
                show-row-number-column
                row-number-offset={rowOffset}
                suppress-bottom-bar
                columns={columns}>
        </lightning-datatable>
    </div>
</template>

User-added image
Hi all  
I have the following class which is called in Flow action when creating events. I am getting the following error when i try to create event.

We can't save this record because the “Type” process failed. Give your Salesforce admin these details. An Apex error occurred: System.LimitException: Too many query rows: 50001 Error ID: 563784318-263669 (-505665031)ccurred: System.LimitException: Too many query rows: 50001 Error ID: 563784318-263669 (-505665031)


The class


public class UpdateNo_ofInterviewsWithTotalActivities {

    // Do not remove this variable as this is used in the trigger to avoid loop
    public static Boolean isUpdatingNumberOfInterviews = false;

  
    /* @description : This method updates opportunity's Number_of_Interviews__c field based on the
    * opportunity's Event subject
    * @param : events list of Event derived from Process builder
    */
    @InvocableMethod public static void updateOppField(List<Event> events) {
        try {
            Set<Id> oppIdsRelatedToEvents = new Set<Id>();

            for (Event evnt : events) {
                String sub = evnt.Subject;
                if (sub != null && (sub.containsIgnoreCase('Interview') || sub.containsIgnoreCase('intvw') || sub.containsIgnoreCase('screen'))) {
                    System.debug('Event Subject is: ' + sub);
                    if (evnt.WhatId != null || evnt.WhatId != '') {
                        oppIdsRelatedToEvents.add(evnt.WhatId);
                    }
                }
            }
            System.debug('oppIdsRelatedToEvents' + oppIdsRelatedToEvents);

            List<Opportunity> oppsList = [SELECT Id, Name, Number_of_Interviews__c FROM Opportunity WHERE Id In:oppIdsRelatedToEvents];
            System.debug('Opportunities with the Event subjects that contains Interview : ' + oppsList);

            List<Event> eventsList = [SELECT Id, WhatId, Subject FROM Event WHERE WhatId In:oppIdsRelatedToEvents];
            System.debug('Events that are related to Opportunities : ' + eventsList);

            Map<Id, Set<Id>> eventOppsMap = new Map<Id, Set<Id>>();
            if (eventsList != null) {
                for (Event e : eventsList) {
                    if (e != null && e.WhatId != null) {
                        String sub = e.Subject;
                        if (sub != null && sub.containsIgnoreCase('Interview') || sub.containsIgnoreCase('intvw') || sub.containsIgnoreCase('screen')) {
                            if (!eventOppsMap.containsKey(e.WhatId)) {
                                Set<Id> eventsIds = new Set<Id>();
                                eventsIds.add(e.Id);
                                eventOppsMap.put(e.WhatId, eventsIds);
                            } else {
                                Set<Id> eventsIds = eventOppsMap.get(e.WhatId);
                                eventsIds.add(e.Id);
                            }
                        }
                    }
                }
            }
            System.debug('Events with Opps map : ' + eventOppsMap);
            List<Opportunity> oppsTobeUpdated = new List<Opportunity>();
            if (oppsList != null) {
                for (Opportunity opp : oppsList) {
                    Set<Id> oppEventIds = eventOppsMap.get(opp.Id);
                    // Do not remove this variable as this is used in the trigger to avoid loop
                    if (oppEventIds.size() > 0)
                        isUpdatingNumberOfInterviews = true;
                    opp.Number_of_Interviews__c = oppEventIds.size();
                    System.debug('Number of Interviews : ' + opp.Number_of_Interviews__c);
                    oppsTobeUpdated.add(opp);
                }
                try {
                    update oppsTobeUpdated;
                }
                catch(DmlException dmle) {
                    System.debug(dmle);
                    System.debug(dmle.getMessage());
                    DBUtils dbUtil = new DBUtils();
                    dbUtil.handleException('Updating opportunities in process builder', dmle.getMessage(), dmle.getLineNumber());
                }
                System.debug('Opps to be updated in the Update No.of Activities class are : ' + oppsTobeUpdated);
            }
        }
        catch(Exception e) {
            system.debug(e);
            system.debug('Exception occurred when updating the events : ' + e.getMessage());
        }
    }
}


In sandbox it is working. In production we are getting this error. Do I need to use Batch Apex? How to implement batch apex in this?
Hi all

I have this following method which is sending email.It was working fine till yesterday. I just changed the message in email template today .when i try to test it showing STORAGE_LIMIT_EXCEEDED exception. I tried with different emails also. It is not working. Can anybody give solution to this.

private void sendEmail(){
        String EmailBody,Subject;
        Contact prjLead;
        String prjLeadEmail;
        List<EmailTemplate> emailTemplateIds = new List<EmailTemplate>();
      
         //Fetch Email Template Id to be send to Candidate and Project Lead 
         
         If(removeProjInterest = True) 
             emailTemplateIds = [SELECT Id,Subject,Body
                                                 FROM EmailTemplate
                                                 WHERE DeveloperName='Request_To_Leave_Project' LIMIT 1] ;
                                                
                                                 
         else                                                   
              emailTemplateIds = [SELECT Id,Subject,Body
                                                 FROM EmailTemplate
                                                 WHERE DeveloperName='Project_Join_Request' LIMIT 1];                                     
        
        //Fetch the Project Lead Details
        If(selPrjLeadId != null){
             prjLead = [SELECT Id,FirstName,Name,Email 
                                         FROM Contact 
                                         WHERE id=:selPrjLeadId 
                                         LIMIT 1];
             projectLead = prjLead.Name; // Value referred in VF Page
             prjLeadEmail = prjLead.Email;
             prjLeadOrManager = 'project lead';  //Value referred in VF Page
        } else{
            //If Project Lead not defined, Email fetched from Custom Metadata settings
            MR_Project_List_Setting__mdt PrjListMetaData = [SELECT PMO_Email__c,PMO_Name__c 
                                                                  FROM MR_Project_List_Setting__mdt
                                                                  WHERE DeveloperName  ='PMO_Details' LIMIT 1];
            projectLead = PrjListMetaData.PMO_Name__c;
            prjLeadEmail = PrjListMetaData.PMO_Email__c;
            prjLeadOrManager = 'project manager';      //Value referred in VF Page
        }
        
        //New instance of a single email message sent to candidate
       Messaging.SingleEmailMessage emailCand = new Messaging.SingleEmailMessage();
       List<String> canEmailList = new List<String>();
       List<String> prjLeadEmailList = new List<String>();
        
        //Fetch the Candidate details
       If(contactId != null){
             
              EmailBody = emailTemplateIds.get(0).Body;
           If(EmailBody !=null){
               EmailBody = EmailBody.replace('Candidate',candFirstName);
               EmailBody = EmailBody.replace('project', selPrjName);                        
               EmailBody = EmailBody.replace('lead',projectLead);
               EmailBody = EmailBody.replace('plOrpm', prjLeadOrManager); 
               EmailBody = EmailBody.replace('LeadEmail',prjLeadEmail);  
               if(removeProjInterest = True) 
               {
               EmailBody = EmailBody.replace('CandEmail',candEmail);
               }
            
           }
              canEmailList.add(candEmail);
              emailCand.toaddresses =canEmailList;
              prjLeadEmailList.add(prjLeadEmail);
              emailCand.ccaddresses = prjLeadEmailList;
              emailCand.setTargetObjectId(contactId);
               Subject = emailTemplateIds[0].Subject;
               emailCand.setSubject(Subject); 
                emailCand.setPlainTextBody(EmailBody);
              try{            
                  Messaging.sendEmail(new Messaging.SingleEmailMessage[] { emailCand });
                  system.debug('Candidate & Project Lead Email Sent Successfully');
              }  catch(exception e){
                      system.debug('Error email');
                      apexpages.addmessage(new apexpages.message(apexpages.severity.error,e.getMessage()));
                      system.debug('Error Sending Candidate and Project Lead email '+e.getMessage());
               }
        
        }
            
 }
    

15:48:46.0 (588298556)|EXCEPTION_THROWN|[338]|System.EmailException: SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: [] 15:48:46.0 (588751848)|HEAP_ALLOCATE|[338]|Bytes:111 15:48:46.0 (588837018)|VARIABLE_SCOPE_BEGIN|[340]|e|Exception|true|false 15:48:46.0 (588947495)|VARIABLE_ASSIGNMENT|[340]|e|"common.apex.methods.MessagingStaticMethods$EmailExecutionException: SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: []"|0xf2b3972 15:48:46.0 (588958756)|STATEMENT_EXECUTE|[340] 15:48:46.0 (588961850)|STATEMENT_EXECUTE|[341] 15:48:46.0 (588991982)|HEAP_ALLOCATE|[341]|Bytes:11 15:48:46.0 (589045155)|USER_DEBUG|[341]|DEBUG|Error email 15:48:46.0 (589057755)|STATEMENT_EXECUTE|[342] 15:48:46.0 (589254533)|HEAP_ALLOCATE|[342]|Bytes:107 15:48:46.0 (589428174)|VF_PAGE_MESSAGE|SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: [] 15:48:46.0 (589439526)|STATEMENT_EXECUTE|[343] 15:48:46.0 (589451863)|HEAP_ALLOCATE|[343]|Bytes:47 15:48:46.0 (589472850)|HEAP_ALLOCATE|[343]|Bytes:107 15:48:46.0 (589489892)|HEAP_ALLOCATE|[343]|Bytes:154 15:48:46.0 (589502124)|USER_DEBUG|[343]|DEBUG|Error Sending Candidate and Project Lead email SendEmail failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: [] 15:48:46.0 (589525677)|METHOD_EXIT|[694]|01p3u00000ILbF5|ProjectsList.sendEmail()