• Lakshmi S
  • NEWBIE
  • 449 Points
  • Member since 2015

  • Chatter
    Feed
  • 1
    Best Answers
  • 6
    Likes Received
  • 0
    Likes Given
  • 88
    Questions
  • 69
    Replies
I am not getting any selectd options in the SelectOption list to show on my Visual Force page. Beow is the VF snippet and controller.

Example
public class sampleConSubmissions {
    
     String[] submissions = new String[]{};

    public sampleConSubmissions(ApexPages.StandardController controller) {

    }
        
            
        public PageReference test() {
            return null;
        }
            
        public List<SelectOption> getItems() {
            List<SelectOption> options = new List<SelectOption>();
            options.add(new SelectOption('TR00025712016 - Umbr only','TR00025712016 - Umbr only'));
            options.add(new SelectOption('TR00028982016 - Casualty','TR00028982016 - Casualty'));
            options.add(new SelectOption('TR18622016 - Casualty','TR18622016 - Casualty'));
            options.add(new SelectOption('TR20612016 - Property','TR20612016 - Property'));
            return options;
        }
            
        public String[] getsubmissions() {
            return submissions;
        }
            
        public void setsubmissions(String[] submissions) {
            this.submissions = submissions;
        }
    }
 
<apex:selectList value="{!submissions}" multiselect="true">
            <apex:selectOptions value="{!items}"/>
        </apex:selectList><p/>

        <apex:commandButton value="Select Submissions" action="{!test}" rerender="out" status="status"/>
    

    <apex:outputPanel id="out">
        <apex:actionstatus id="status" startText="testing...">
            <apex:facet name="stop">
                <apex:outputPanel >
                    <p>You have selected:</p>
                    <apex:dataList value="{!submissions}" var="c">{!c}</apex:dataList>
                </apex:outputPanel>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputPanel>

 
Hi Team,

I am using analytical report chart in visualforce page.
I want to pass the record id to report for filtering process?
<apex:pageBlockSection title="Dashboard" columns="2">
                <analytics:reportChart reportId="00O4F000000JUVJ" filter="[{column:'HIGH_RISK_SUCCESS_FACTORS__C.ID',operator:'equals',value:'{!High_Risk_Success_Factors__c.Id}'}]" size="tiny" showRefreshButton="true" />
</apex:pageBlockSection>
I am getting error like, Invalid column variables.
Please let me know how can we resolve this?

Thanks
Lakhsmi
 
Hi Team,

I am using standard clone functionality for cloning the record. but my code override the existing record, instead of creating new record.
public PageReference doClone(){
        try{
            //con.save();
            PageReference pr = Page.HighRiskSuccessFactorsVFPage;
            pr.setRedirect(true);
            pr.getParameters().put('id',con.getId());
            return pr;
        }catch(Exception e){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));
            return null;
        }
    }
Please let me know, how can we achieve this using custom functionality.

Thanks
Lakshmi.
 
Hi Team,
How to hide save and cancel button in custom detail page?
<apex:pageBlockButtons >
                
                <apex:commandButton value="Save" action="{!Save}" id="saveButton" />
              <!--  <apex:commandButton value="Save & New" action="{!saveNew}"/> -->
                <apex:commandButton value="Edit" action="{!Edit}" id="editButton" />
                <apex:commandButton value="Delete" action="{!Delete}" onclick="if(!confirm('Are you sure?')){return false};" id="deleteButton" />
                <apex:commandButton value="Clone" action="{!doClone}" id="cloneButton" />
               <apex:commandButton value="Cancel" action="{!doCancel}" id="cancelButton" immediate="true" />
            </apex:pageBlockButtons>

Please let me know how can we do this in visualforce page...

Thanks.
Lakshmi.
 
Hi Team,

How to redirect the custom vf page to custom object after clicking on Cancel button?
public with sharing class HighRiskSuccessFactorsCls {
    
    public High_Risk_Success_Factors__c hrsf {get;set;}
    ApexPages.StandardController con;
    public HighRiskSuccessFactorsCls(ApexPages.StandardController sc){
        con=sc;
    }
    
    public PageReference saveNew()
     { 
         PageReference pr; 
         try{ con.save();
         Schema.DescribeSObjectResult describeResult = con.getRecord().getSObjectType().getDescribe();
         pr = new PageReference('/' + describeResult.getKeyPrefix() + '/e');
         pr.setRedirect(true);
         return pr;
         }catch(Exception e){ 
         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, e.getMessage()));
         return null; }
     
     }
    Public PageReference doCancel(){
        PageReference pageRef = new PageReference('/apex/High_Risk_Success_Factors__c?id='+hrsf.id+'&Sfdc.override=1');
    	pageRef.getParameters().put('tab','High Risk Success Factors');
    	return pageRef;	
    }

}
Please let me know how can i redirect to custom object tab.

Thanks.
Lakshmi
 
Hi Team,

How to change the below url for updated URL format for Lightning Experience?
https://na31.lightning.force.com/one/one.app#/sObject/00O37000001wEdF/view?a%3At=1509417250603&fv0={! Account.Id }

Thanks.
Lakshmi.
HI Team,

How to write a validation rule for hide picklist value based on other picklist value selection?
I have two picklist fields A and B.
A have one & two values.
B have one & two values.
If i select one from A, it doesn't show one in the B field.
How can we achieve that?

Thanks.
Lakshmi
 
Hi Team,

I have written a trigger for Rollup summary.
In my code, it doesn't calculte the value if parent object doesn't have child records.
code :
----------
public class KingsleyRollupSummaryTrigHandlerCls {
    
    Public static String recordYear = '2017';

    Public Static void deleteRecords(List<KingsleyTranscript__c> delrecs){
        
        try{
             Set<String> accIds = new Set<String>(); 
        for(KingsleyTranscript__c kt : delrecs){
            if(kt.Account_Name__c != null){
                system.debug('-------'+kt.Account_Name__c);
                accIds.add(kt.Account_Name__c);
            }
        }

            if(accIds.size() > 0){
                
            Map<Id,Account> accountMap = new Map<Id,Account>([Select id,RS_Reg_Client_Satisfaction_Ams_Sum__c,RS_Reg_Client_Satisfaction_Ams_Count__c,RS_Reg_Client_Satisfaction_EMEA_Sum__c,
                               RS_Reg_Client_Satisfaction_EMEA_Count__c,RS_Reg_Client_Satisfaction_APAC_Sum__c,RS_Reg_Client_Satisfaction_APAC_Count__c,
                               RS_Overall_Satisfaction_Rating_Sum__c,RS_Overall_Satisfaction_Rating_Count__c,RS_Value_Contribution_Rating_Sum__c,
                               RS_Value_Contribution_Rating_Count__c,RS_AD_Overall_Rating_Sum__c,RS_AD_Overall_Rating_Count__c,RS_TM_PA_Overall_Rating_Sum__c,
                               RS_TM_PA_Overall_Rating_Count__c,RS_TM_Leader_Rating_Sum__c,RS_TM_Leader_Rating_Count__c,RS_TM_PA_Off_Acct_Leader_Rating_Sum__c,
                               RS_TM_PA_Off_Acct_Leader_Rating_Count__c,RS_FM_Overall_Rating_Sum__c,RS_FM_Overall_Rating_Count__c,RS_FM_Leader_Rating_Sum__c,
                               RS_FM_Leader_Rating_Count__c,RS_FM_Off_Acct_Leadership_Rating_Sum__c,RS_FM_Off_Acct_Leadership_Rating_Count__c,RS_PJM_Overall_Rating_Sum__c,
                               RS_PJM_Overall_Rating_Count__c,RS_PJM_Leader_Rating_Sum__c,RS_PJM_Leader_Rating_Count__c,RS_PJM_Off_Acct_Leadership_Rating_Sum__c,
                               RS_PJM_Off_Acct_Leadership_Rating_Count__c,RS_REMC_Overall_Rating_Sum__c,RS_REMC_Overall_Rating_Count__c,RS_Off_Acct_REMC_Leader_Rating_Sum__c,
                               RS_Off_Acct_REMC_Leader_Rating_Count__c,RS_Thought_Leadership_progs_Rating_Sum__c,RS_Thought_Leadership_prog_Rating_Count__c,
                               RS_Exec_Leadership_Overall_Rating_Sum__c,RS_Exec_Leadership_Overall_Rating_Count__c,RS_Peer_Recommendation_NPS_Rating_Sum__c,RS_Peer_Recommend_NPS_Rating_Count__c from Account where Id IN :accIds]);
            
            Account a = null;
              
                  for(AggregateResult agResult : [Select Account_Name__c,Recorded_Year__c, SUM(Regional_Client_Satisfaction_Americas__c)amsum,COUNT(Regional_Client_Satisfaction_Americas__c)amcount,COUNT(Regional_Client_Satisfaction_APAC__c)apaccount,SUM(Regional_Client_Satisfaction_APAC__c)apacsum,COUNT(Regional_Client_Satisfaction_EMEA__c)emeacount,SUM(Regional_Client_Satisfaction_EMEA__c)emeasum from 
                                                  KingsleyTranscript__c where Account_Name__c IN :accIds and Recorded_Year__c =:recordYear Group By Account_Name__c,Recorded_Year__c]){
                                                      
                         String aId = (String)agResult.get('Account_Name__c');
                         a=accountMap.get(aId);
                         a.RS_Reg_Client_Satisfaction_Ams_Sum__c = (Decimal)agResult.get('amsum');
                         a.RS_Reg_Client_Satisfaction_Ams_Count__c = (Integer)agResult.get('amcount');
                         a.RS_Reg_Client_Satisfaction_APAC_Sum__c = (Decimal)agResult.get('apacsum');
                         a.RS_Reg_Client_Satisfaction_APAC_Count__c = (Integer)agResult.get('apaccount');
                         a.RS_Reg_Client_Satisfaction_EMEA_Sum__c = (Decimal)agResult.get('emeasum');
                         a.RS_Reg_Client_Satisfaction_EMEA_Count__c = (Integer)agResult.get('emeacount');
                         //accountsToUpdate.add(a);
                         accountMap.put(aId, a);
          
                       }
                
        update accountMap.values();
                
            }  

        }
        catch(Exception ex){
            ex.getMessage();
        }
    }
    
}
Please let me know how to do this..........

Regards
Lakshmi

 
HI Team,
AfterInsert caused by: System.QueryException: Aggregate query has too many rows for direct assignment, use FOR loop External entry point.
AfterInsert caused by: System.QueryException: Aggregate query has too many rows for direct assignment, use FOR loop External entry point

public class KingsleyRollupSummaryTrigHandlerCls {
    
    // Declaring static variables for count,sum and record year.
    
    Public static String recordYear = '2017';
    Public static Decimal amsum ;
    Public static Integer amcount ;
    Public static Decimal emeasum ;
    Public static Integer emeacount ;
    Public static Decimal apacsum ;
    Public static Integer apaccount ;
    
    
    
    // Static insert method...
    Public Static void insertRecords(List<KingsleyTranscript__c> newrecs){
        
        Set<String> accIds = new Set<String>(); 
        for(KingsleyTranscript__c kt : newrecs){
            if(kt.Account_Name__c != null){
                accIds.add(kt.Account_Name__c);
            }
        }
        
            //List<Account> accountsToUpdate = new List<Account>();
            //List<Account> accountsToUpdate2 = new List<Account>();
            
            Map<Id,Account> updateAccMap = new Map<Id,Account>(); 
            
            Map<Id,Account> accountMap = new Map<Id,Account>([Select id,RS_Reg_Client_Satisfaction_Ams_Sum__c,RS_Reg_Client_Satisfaction_Ams_Count__c,RS_Reg_Client_Satisfaction_EMEA_Sum__c,
                               RS_Reg_Client_Satisfaction_EMEA_Count__c,RS_Reg_Client_Satisfaction_APAC_Sum__c,RS_Reg_Client_Satisfaction_APAC_Count__c,
                               RS_Overall_Satisfaction_Rating_Sum__c,RS_Overall_Satisfaction_Rating_Count__c,RS_Value_Contribution_Rating_Sum__c,
                               RS_Value_Contribution_Rating_Count__c,RS_AD_Overall_Rating_Sum__c,RS_AD_Overall_Rating_Count__c,RS_TM_PA_Overall_Rating_Sum__c,
                               RS_TM_PA_Overall_Rating_Count__c,RS_TM_Leader_Rating_Sum__c,RS_TM_Leader_Rating_Count__c,RS_TM_PA_Off_Acct_Leader_Rating_Sum__c,
                               RS_TM_PA_Off_Acct_Leader_Rating_Count__c,RS_FM_Overall_Rating_Sum__c,RS_FM_Overall_Rating_Count__c,RS_FM_Leader_Rating_Sum__c,
                               RS_FM_Leader_Rating_Count__c,RS_FM_Off_Acct_Leadership_Rating_Sum__c,RS_FM_Off_Acct_Leadership_Rating_Count__c,RS_PJM_Overall_Rating_Sum__c,
                               RS_PJM_Overall_Rating_Count__c,RS_PJM_Leader_Rating_Sum__c,RS_PJM_Leader_Rating_Count__c,RS_PJM_Off_Acct_Leadership_Rating_Sum__c,
                               RS_PJM_Off_Acct_Leadership_Rating_Count__c,RS_REMC_Overall_Rating_Sum__c,RS_REMC_Overall_Rating_Count__c,RS_Off_Acct_REMC_Leader_Rating_Sum__c,
                               RS_Off_Acct_REMC_Leader_Rating_Count__c,RS_Thought_Leadership_progs_Rating_Sum__c,RS_Thought_Leadership_prog_Rating_Count__c,
                               RS_Exec_Leadership_Overall_Rating_Sum__c,RS_Exec_Leadership_Overall_Rating_Count__c,RS_Peer_Recommendation_NPS_Rating_Sum__c,RS_Peer_Recommend_NPS_Rating_Count__c
                                                              from Account where Id In :accIds]);
            
                             
            // for 'Regional_Client_Satisfaction_Americas__c' field value calculation
                
            for(AggregateResult agres : [Select Account_Name__c,Recorded_Year__c, SUM(Regional_Client_Satisfaction_Americas__c)amsum,
                                         COUNT(Regional_Client_Satisfaction_Americas__c)amcount,SUM(Regional_Client_Satisfaction_APAC__c)apacsum,
                                         COUNT(Regional_Client_Satisfaction_APAC__c)apaccount,SUM(Regional_Client_Satisfaction_EMEA__c)emeasum,
                                         COUNT(Regional_Client_Satisfaction_EMEA__c)emeacount from 
                                         KingsleyTranscript__c where Account_Name__c IN :accIds and (Regional_Client_Satisfaction_Americas__c >0 or Regional_Client_Satisfaction_Americas__c >0 or Regional_Client_Satisfaction_EMEA__c >0) and Recorded_Year__c=: recordYear Group By Account_Name__c,Recorded_Year__c]){
                                             String aId = (String)agres.get('Account_Name__c');
                                             Account a = accountMap.get(aId);
                                             a.RS_Reg_Client_Satisfaction_Ams_Count__c = (Decimal)agres.get('amcount');
                                             a.RS_Reg_Client_Satisfaction_Ams_Sum__c = (Decimal)agres.get('amsum');
                                             a.RS_Reg_Client_Satisfaction_APAC_Count__c = (Decimal)agres.get('apaccount');
                                             a.RS_Reg_Client_Satisfaction_APAC_Sum__c = (Decimal)agres.get('apacsum');
                                             a.RS_Reg_Client_Satisfaction_EMEA_Count__c = (Decimal)agres.get('emeacount');
                                             a.RS_Reg_Client_Satisfaction_EMEA_Sum__c = (Decimal)agres.get('emeasum');
         
 
                                             
                                             //accountsToUpdate.add(a);
                                             updateAccMap.put(a.Id, a);
                
            }
}

Can any one let me know, how to do this.......
Hi Team,

Requirement : Calculating sum and  count using Trigger. We have to calculate for 20 fields in child object.
1. For each field we have to check condition  : year, accountname(parent id) and field value.
2. For this i am using aggregate result function individually, because of that i am getting soql query exception.
SOQL Query Exception : AggregateResult caused too many rows exception?
Trigger:
------------
trigger KingsleyRollupSummaryTrig on KingsleyTranscript__c (after insert, after Update, after delete, after undelete) {
    
    /*
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUndelete)){
        KingsleyRollupSummaryTrigHandlerCls.insertRecords((List<KingsleyTranscript__c>)Trigger.New);
    }
    
    if(Trigger.isAfter && Trigger.isUpdate){
        //KingsleyRollupSummaryTrigHandlerCls.updateRecords((List<KingsleyTranscript__c>)Trigger.old);
    }
    
    if(Trigger.isAfter && Trigger.isDelete){
       // KingsleyRollupSummaryTrigHandlerCls.deleteRecords((List<KingsleyTranscript__c>)Trigger.old);
    }
*/
    String recordYear = '2017';
      Decimal amsum ;
      Integer amcount ;
      Decimal emeasum ;
      Integer emeacount ;
      Decimal apacsum ;
      Integer apaccount ;
      Decimal osrsum ;
      Integer osrcount ;
      Decimal vcrsum ;
      Integer vcrcount ;
      Decimal adorsum ;
      Integer adorcount ;
      Decimal tmpaorsum ;
      Integer tmpaorcount ;
      Decimal tmlrsum ;
      Integer tmlrcount ;
	  Decimal tmpa_off_acct_sum ;
      Integer tmpa_off_acct_count ;
      Decimal fm_or_sum ;
      Integer fm_or_count ;
      Decimal fm_lr_sum ;
      Integer fm_lr_count ;
      Decimal fm_off_acct_lr_sum ;
      Integer fm_off_acct_lr_count ;
      Decimal pjm_off_acct_lr_sum ;
      Integer pjm_off_acct_lr_count ;
      Decimal pjm_or_sum ;
      Integer pjm_or_count ;
      Decimal pjm_lr_sum ;
      Integer pjm_lr_count ;
      Decimal remc_or_sum ;
      Integer remc_or_count ;
      Decimal off_acct_remc_sum ;
      Integer off_acct_remc_count ;
      Decimal thought_lp_sum ;
      Integer thought_lp_count ;
      Decimal exec_or_sum ;
      Integer exec_or_count ;
      Decimal peer_nps_sum ;
      Integer peer_nps_count ;

        
      List<Account> updateAccs = new List<Account>();
      Set<Id> accIds = new Set<Id>();
      
    
    
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete)){
        
        
        for(KingsleyTranscript__c kt : Trigger.New){
            
            if(kt.Account_Name__c != null){
                accIds.add(kt.Account_Name__c);
            }
        }
    }
    
    if(Trigger.isAfter && (Trigger.isUpdate || Trigger.isDelete)){
        
        
        for(KingsleyTranscript__c kt : Trigger.New){
            
            if(kt.Account_Name__c != null){
                accIds.add(kt.Account_Name__c);
            }
        }
    }
    
   
        
        if(accIds.size() > 0){
            List<Account> acclist = [Select id,name,RS_Reg_Client_Satisfaction_Ams_Sum__c,RS_Reg_Client_Satisfaction_Ams_Count__c,RS_Reg_Client_Satisfaction_EMEA_Sum__c,
                               RS_Reg_Client_Satisfaction_EMEA_Count__c,RS_Reg_Client_Satisfaction_APAC_Sum__c,RS_Reg_Client_Satisfaction_APAC_Count__c,
                               RS_Overall_Satisfaction_Rating_Sum__c,RS_Overall_Satisfaction_Rating_Count__c,RS_Value_Contribution_Rating_Sum__c,
                               RS_Value_Contribution_Rating_Count__c,RS_AD_Overall_Rating_Sum__c,RS_AD_Overall_Rating_Count__c,RS_TM_PA_Overall_Rating_Sum__c,
                               RS_TM_PA_Overall_Rating_Count__c,RS_TM_Leader_Rating_Sum__c,RS_TM_Leader_Rating_Count__c,RS_TM_PA_Off_Acct_Leader_Rating_Sum__c,
                               RS_TM_PA_Off_Acct_Leader_Rating_Count__c,RS_FM_Overall_Rating_Sum__c,RS_FM_Overall_Rating_Count__c,RS_FM_Leader_Rating_Sum__c,
                               RS_FM_Leader_Rating_Count__c,RS_FM_Off_Acct_Leadership_Rating_Sum__c,RS_FM_Off_Acct_Leadership_Rating_Count__c,RS_PJM_Overall_Rating_Sum__c,
                               RS_PJM_Overall_Rating_Count__c,RS_PJM_Leader_Rating_Sum__c,RS_PJM_Leader_Rating_Count__c,RS_PJM_Off_Acct_Leadership_Rating_Sum__c,
                               RS_PJM_Off_Acct_Leadership_Rating_Count__c,RS_REMC_Overall_Rating_Sum__c,RS_REMC_Overall_Rating_Count__c,RS_Off_Acct_REMC_Leader_Rating_Sum__c,
                               RS_Off_Acct_REMC_Leader_Rating_Count__c,RS_Thought_Leadership_progs_Rating_Sum__c,RS_Thought_Leadership_prog_Rating_Count__c,
                               RS_Exec_Leadership_Overall_Rating_Sum__c,RS_Exec_Leadership_Overall_Rating_Count__c,RS_Peer_Recommendation_NPS_Rating_Sum__c,RS_Peer_Recommend_NPS_Rating_Count__c,
                               (Select id,Regional_Client_Satisfaction_Americas__c,Regional_Client_Satisfaction_EMEA__c,Regional_Client_Satisfaction_APAC__c,
                                Overall_satisfaction_Rating__c,Value_Contribution_Rating__c,Additional_Vakue_Focus_Areas__c,AD_Overall_Rating__c,
                                TM_PA_Overall_Rating__c,TM_Leader_Rating__c,TM_PA_Off_Account_Leader_Rating__c,FM_Overall_Rating__c,FM_Leader_Rating__c,
                                FM_Off_Acct_Lship_Rating__c,PJM_Overall_Rating__c,PJM_Leader_Rating__c,PJM_Off_Acct_Leadership_Rating__c,REMC_Overall_Rating__c,
                                Off_Account_REMC_Leader_Rating__c,Thought_Ldrship_Pgm_Rating__c,Exec_Ldrship_Overall_Rating__c,Peer_Recomend_NPS_Rating__c,
                                Recorded_Year__c from Kingsley_Transcript__r) from Account where Id In :accIds];
            
            for(Account acc : acclist){
                                   
                // for 'Regional_Client_Satisfaction_Americas__c' field value calculation
                AggregateResult[] agres = [Select SUM(Regional_Client_Satisfaction_Americas__c)amsum,COUNT(Regional_Client_Satisfaction_Americas__c)amcount 
                                   	            from KingsleyTranscript__c where Account_Name__c =: acc.id and Regional_Client_Satisfaction_Americas__c > 0 and Recorded_Year__c=: recordYear];
                
                
                if(agres.size() > 0){
                    
                     for(AggregateResult ag : agres){
                                                                 
                          amsum = (Decimal)ag.get('amsum');
                          amcount = (Integer)ag.get('amcount');
                      }
                      acc.RS_Reg_Client_Satisfaction_Ams_Sum__c = amsum;
                      acc.RS_Reg_Client_Satisfaction_Ams_Count__c = amcount;
                    
                }
               // for 'Regional_Client_Satisfaction_EMEA__c' field value calculation
                AggregateResult[] agres2 = [Select SUM(Regional_Client_Satisfaction_EMEA__c)emeasum,COUNT(Regional_Client_Satisfaction_EMEA__c)emeacount 
                                               from KingsleyTranscript__c where Account_Name__c =: acc.id and Regional_Client_Satisfaction_EMEA__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres2.size() > 0){
                    
                    for(AggregateResult ag : agres2){
                                                                 
                                                                 emeasum = (Decimal)ag.get('emeasum');
                                                                 emeacount = (Integer)ag.get('emeacount');
                                                                 
                                                             }
                                   acc.RS_Reg_Client_Satisfaction_EMEA_Sum__c = emeasum;
                                   acc.RS_Reg_Client_Satisfaction_EMEA_Count__c = emeacount;
                    
                }               
                                   // for 'Regional_Client_Satisfaction_APAC__c' field value calculation
                AggregateResult[] agres3 = [Select SUM(Regional_Client_Satisfaction_APAC__c)apacsum,COUNT(Regional_Client_Satisfaction_APAC__c)apaccount 
                                                from KingsleyTranscript__c where Account_Name__c =: acc.id and Regional_Client_Satisfaction_APAC__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres3.size() > 0){
                    for(AggregateResult ag : agres3){
                                                                 
                                                                 apacsum = (Decimal)ag.get('apacsum');
                                                                 apaccount = (Integer)ag.get('apaccount');
                                                                 
                                                             }
                                   acc.RS_Reg_Client_Satisfaction_APAC_Sum__c = apacsum;
                                   acc.RS_Reg_Client_Satisfaction_APAC_Count__c = apaccount;
             
                }
            
                                    
                                   // for 'Overall_satisfaction_Rating__c' field value calculation
                AggregateResult[] agres4 = [Select SUM(Overall_satisfaction_Rating__c)osrsum,COUNT(Overall_satisfaction_Rating__c)osrcount 
                                                from KingsleyTranscript__c where Account_Name__c =: acc.id and Overall_satisfaction_Rating__c > 0 and Recorded_Year__c=: recordYear];                 
                
                if(agres4.size() > 0){
                    for(AggregateResult ag : agres4){
                                                                 
                                                                 osrsum = (Decimal)ag.get('osrsum');
                                                                 osrcount = (Integer)ag.get('osrcount');
                                                                 
                                                             }
                                   acc.RS_Overall_Satisfaction_Rating_Sum__c = osrsum;
                                   acc.RS_Overall_Satisfaction_Rating_Count__c = osrcount;

                }
                				   // for 'Value_Contribution_Rating__c' field value calculation
                AggregateResult[] agres5 = [Select SUM(Value_Contribution_Rating__c)vcrsum,COUNT(Value_Contribution_Rating__c)vcrcount from KingsleyTranscript__c where Account_Name__c =: acc.id and Value_Contribution_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                
                if(agres5.size() > 0){
                    for(AggregateResult ag : agres5){
                                                                 
                                                                 vcrsum = (Decimal)ag.get('vcrsum');
                                                                 vcrcount = (Integer)ag.get('vcrcount');
                                                                 
                                                             }
                                   acc.RS_Value_Contribution_Rating_Sum__c = vcrsum;
                                   acc.RS_Value_Contribution_Rating_Count__c = vcrcount;

                }
               
                                   // for 'AD_Overall_Rating__c' field value calculation
                AggregateResult[] agres6 = [Select SUM(AD_Overall_Rating__c)adorsum,COUNT(AD_Overall_Rating__c)adorcount from KingsleyTranscript__c where Account_Name__c =: acc.id and AD_Overall_Rating__c > 0 and Recorded_Year__c=: recordYear];                  
                if(agres6.size() > 0){
                    for(AggregateResult ag : agres6){
                                                                 
                                                                 adorsum = (Decimal)ag.get('adorsum');
                                                                 adorcount = (Integer)ag.get('adorcount');
                                                                 
                                                             }
                                   acc.RS_AD_Overall_Rating_Sum__c = adorsum;
                                   acc.RS_AD_Overall_Rating_Count__c = adorcount;

                }                                   
                                   
 								   // for 'TM_PA_Overall_Rating__c' field value calculation
                AggregateResult[] agres7 = [Select SUM(TM_PA_Overall_Rating__c)tmpaorsum,COUNT(TM_PA_Overall_Rating__c)tmpaorcount 
                                                from KingsleyTranscript__c where Account_Name__c =: acc.id and TM_PA_Overall_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres7.size() > 0){
                    for(AggregateResult ag : agres7){
                                                                 
                                                                 tmpaorsum = (Decimal)ag.get('tmpaorsum');
                                                                 tmpaorcount = (Integer)ag.get('tmpaorcount');
                                                                 
                                                             }
                                   acc.RS_TM_PA_Overall_Rating_Sum__c = tmpaorsum;
                                   acc.RS_TM_PA_Overall_Rating_Count__c = tmpaorcount;

                }

 							       // for 'TM_Leader_Rating__c' field value calculation
                AggregateResult[] agres8 = [Select SUM(TM_Leader_Rating__c)tmlrsum,COUNT(TM_Leader_Rating__c)tmlrcount 
                                                from KingsleyTranscript__c where Account_Name__c =: acc.id and TM_Leader_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                
                if(agres8.size() > 0){
                    for(AggregateResult ag : agres8){
                                                                 
                                                                 tmlrsum = (Decimal)ag.get('tmlrsum');
                                                                 tmlrcount = (Integer)ag.get('tmlrcount');
                                                                 
                                                             }
                                   acc.RS_TM_Leader_Rating_Sum__c = tmlrsum;
                                   acc.RS_TM_Leader_Rating_Count__c = tmlrcount;

                }

								 // for 'TM_PA_Off_Account_Leader_Rating__c' field value calculation
                AggregateResult[] agres9 = [Select SUM(TM_PA_Off_Account_Leader_Rating__c)tmpa_off_acct_sum,COUNT(TM_PA_Off_Account_Leader_Rating__c)tmpa_off_acct_count 
                                                from KingsleyTranscript__c where Account_Name__c =: acc.id and TM_PA_Off_Account_Leader_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres9.size() > 0){
                    for(AggregateResult ag :agres9 ){
                                                                 
                                                                 tmpa_off_acct_sum = (Decimal)ag.get('tmpa_off_acct_sum');
                                                                 tmpa_off_acct_count = (Integer)ag.get('tmpa_off_acct_count');
                                                                 
                                                             }
                                   acc.RS_TM_PA_Off_Acct_Leader_Rating_Sum__c = tmpa_off_acct_sum;
                                   acc.RS_TM_PA_Off_Acct_Leader_Rating_Count__c = tmpa_off_acct_count;

                }                                    
                                    // for 'FM_Overall_Rating__c' field value calculation
                AggregateResult[] agres10 = [Select SUM(FM_Overall_Rating__c)fm_or_sum,COUNT(FM_Overall_Rating__c)fm_or_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and FM_Overall_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres10.size() > 0){
                    for(AggregateResult ag : agres10){
                                                                 
                                                                 fm_or_sum = (Decimal)ag.get('fm_or_sum');
                                                                 fm_or_count = (Integer)ag.get('fm_or_count');
                                                                 
                                                             }
                                   acc.RS_FM_Overall_Rating_Sum__c = fm_or_sum;
                                   acc.RS_FM_Overall_Rating_Count__c = fm_or_count;

                }
 								// for 'FM_Leader_Rating__c' field value calculation
                                   
                AggregateResult[] agres11 = [Select SUM(FM_Leader_Rating__c)fm_lr_sum,COUNT(FM_Leader_Rating__c)fm_lr_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and FM_Leader_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres11.size() > 0){
                    for(AggregateResult ag : agres11){
                                                                 
                                                                 fm_lr_sum = (Decimal)ag.get('fm_lr_sum');
                                                                 fm_lr_count = (Integer)ag.get('fm_lr_count');
                                                                 
                                                             }
                                   acc.RS_FM_Leader_Rating_Sum__c = fm_lr_sum;
                                   acc.RS_FM_Leader_Rating_Count__c = fm_lr_count;

                }
								 // for 'FM_Off_Acct_Lship_Rating__c' field value calculation
                AggregateResult[] agres12 = [Select SUM(FM_Off_Acct_Lship_Rating__c)fm_off_acct_lr_sum,COUNT(FM_Off_Acct_Lship_Rating__c)fm_off_acct_lr_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and FM_Off_Acct_Lship_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres12.size() >0){
                    for(AggregateResult ag : agres12){
                                                                 
                                                                 fm_off_acct_lr_sum = (Decimal)ag.get('fm_off_acct_lr_sum');
                                                                 fm_off_acct_lr_count = (Integer)ag.get('fm_off_acct_lr_count');
                                                                 
                                                             }
                                   acc.RS_FM_Off_Acct_Leadership_Rating_Sum__c = fm_off_acct_lr_sum;
                                   acc.RS_FM_Off_Acct_Leadership_Rating_Count__c = fm_off_acct_lr_count;

                }                                    
                                    
                                    // for 'PJM_Overall_Rating__c' field value calculation
                AggregateResult[] agres13 = [Select SUM(PJM_Overall_Rating__c)pjm_or_sum,COUNT(PJM_Overall_Rating__c)pjm_or_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and PJM_Overall_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres13.size() > 0){
                    for(AggregateResult ag : agres13){
                                                                 
                                                                 pjm_or_sum = (Decimal)ag.get('pjm_or_sum');
                                                                 pjm_or_count = (Integer)ag.get('pjm_or_count');
                                                                 
                                                             }
                                   acc.RS_PJM_Overall_Rating_Sum__c = pjm_or_sum;
                                   acc.RS_PJM_Overall_Rating_Count__c = pjm_or_count;

                }
 								// for 'PJM_Leader_Rating__c' field value calculation
                AggregateResult[] agres14 = [Select SUM(PJM_Leader_Rating__c)pjm_lr_sum,COUNT(PJM_Leader_Rating__c)pjm_lr_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and PJM_Leader_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres14.size()>0){
                    for(AggregateResult ag : agres14){
                                                                 
                                                                 pjm_lr_sum = (Decimal)ag.get('pjm_lr_sum');
                                                                 pjm_lr_count = (Integer)ag.get('pjm_lr_count');
                                                                 
                                                             }
                                   acc.RS_PJM_Leader_Rating_Sum__c = pjm_lr_sum;
                                   acc.RS_PJM_Leader_Rating_Count__c = pjm_lr_count;

                }
                
								 // for 'PJM_Off_Acct_Leadership_Rating__c field value calculation
	             AggregateResult[] agres15 = [Select SUM(PJM_Off_Acct_Leadership_Rating__c)pjm_off_acct_lr_sum,COUNT(PJM_Off_Acct_Leadership_Rating__c)pjm_off_acct_lr_count 
                                                  from KingsleyTranscript__c where Account_Name__c =: acc.id and PJM_Off_Acct_Leadership_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres15.size() > 0){
                    for(AggregateResult ag : agres15){
                                                                 
                                                                 pjm_off_acct_lr_sum = (Decimal)ag.get('pjm_off_acct_lr_sum');
                                                                 pjm_off_acct_lr_count = (Integer)ag.get('pjm_off_acct_lr_count');
                                                                 
                                                             }
                                   acc.RS_PJM_Off_Acct_Leadership_Rating_Sum__c = pjm_off_acct_lr_sum;
                                   acc.RS_PJM_Off_Acct_Leadership_Rating_Count__c = pjm_off_acct_lr_count;
                                   
                }
                                    
                                    // for 'REMC_Overall_Rating__c' field value calculation
                 AggregateResult[] agres16 = [Select SUM(REMC_Overall_Rating__c)remc_or_sum,COUNT(REMC_Overall_Rating__c)remc_or_count
                                                  from KingsleyTranscript__c where Account_Name__c =: acc.id and REMC_Overall_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres16.size()>0){
                                   for(AggregateResult ag : agres16){
                                                                 
                                                                 remc_or_sum = (Decimal)ag.get('remc_or_sum');
                                                                 remc_or_count = (Integer)ag.get('remc_or_count');
                                                                 
                                                             }
                                   acc.RS_REMC_Overall_Rating_Sum__c = remc_or_sum;
                                   acc.RS_REMC_Overall_Rating_Count__c = remc_or_count;

                }
                    
 								// for 'Off_Account_REMC_Leader_Rating__c' field value calculation
 				AggregateResult[] agres17 = [Select SUM(Off_Account_REMC_Leader_Rating__c)off_acct_remc_sum,COUNT(Off_Account_REMC_Leader_Rating__c)off_acct_remc_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and Off_Account_REMC_Leader_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres17.size()>0){
                                   for(AggregateResult ag : agres17) {
                                                                 
                                                                 off_acct_remc_sum = (Decimal)ag.get('off_acct_remc_sum');
                                                                 off_acct_remc_count = (Integer)ag.get('off_acct_remc_count');
                                                                 
                                                             }
                                   acc.RS_Off_Acct_REMC_Leader_Rating_Sum__c = off_acct_remc_sum;
                                   acc.RS_Off_Acct_REMC_Leader_Rating_Count__c = off_acct_remc_count;

                }
                    
								 // for 'Thought_Ldrship_Pgm_Rating__c field value calculation
		        AggregateResult[] agres18 = [Select SUM(Thought_Ldrship_Pgm_Rating__c)thought_lp_sum,COUNT(Thought_Ldrship_Pgm_Rating__c)thought_lp_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and Thought_Ldrship_Pgm_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres18.size()>0){
                                   for(AggregateResult ag : agres18){
                                                                 
                                                                 thought_lp_sum = (Decimal)ag.get('thought_lp_sum');
                                                                 thought_lp_count = (Integer)ag.get('thought_lp_count');
                                                                 
                                                             }
                                   acc.RS_Thought_Leadership_progs_Rating_Sum__c = thought_lp_sum;
                                   acc.RS_Thought_Leadership_prog_Rating_Count__c = thought_lp_count;

                }
 								// for 'Exec_Ldrship_Overall_Rating__c' field value calculation
                AggregateResult[] agres19 = [Select SUM(Exec_Ldrship_Overall_Rating__c)exec_or_sum,COUNT(Exec_Ldrship_Overall_Rating__c)exec_or_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and Exec_Ldrship_Overall_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres19.size()>0){
                    for(AggregateResult ag : agres19){
                                                                 
                                                                 exec_or_sum = (Decimal)ag.get('exec_or_sum');
                                                                 exec_or_count = (Integer)ag.get('exec_or_count');
                                                                 
                                                             }
                                   acc.RS_Exec_Leadership_Overall_Rating_Sum__c = exec_or_sum;
                                   acc.RS_Exec_Leadership_Overall_Rating_Count__c = exec_or_count;
                }
 								// for 'Peer_Recomend_NPS_Rating__c' field value calculation
                AggregateResult[] agres20 = [Select SUM(Peer_Recomend_NPS_Rating__c)peer_nps_sum,COUNT(Peer_Recomend_NPS_Rating__c)peer_nps_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and Peer_Recomend_NPS_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres20.size()>0){
                    for(AggregateResult ag : agres20){
                                                                 
                                                                 peer_nps_sum = (Decimal)ag.get('peer_nps_sum');
                                                                 peer_nps_count = (Integer)ag.get('peer_nps_count');
                                                                 
                                                             }
                                   acc.RS_Peer_Recommendation_NPS_Rating_Sum__c = peer_nps_sum;
                                   acc.RS_Peer_Recommend_NPS_Rating_Count__c = peer_nps_count;               
                }
                                   updateAccs.add(acc);
            }         
               Database.update(updateAccs,false);   
        }   
}
Can any one let me know how to solve this problem?

Regards
Lakshmi S
 
Hi Team,

How to reduce (bulkify) code using Map?

Trigger
---------------
trigger FinancialsRollupSummary on Financials__c (after insert, after update, after delete, after undelete) {
    
    // If condition for After insert and undelete records.
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUndelete)){
       
        // Calling Handler class Insert method.
        FinancialsRollupSummaryHandlerCls.insertFinancials((List<Financials__c>)Trigger.New);
    }
    
    // If condition for After delete records.
    if(Trigger.isAfter && Trigger.isDelete){
        
        // Calling Handler class Delete method.
        FinancialsRollupSummaryHandlerCls.deleteFinancials((List<Financials__c>)Trigger.Old);
    }
    
    // If condition for After Update records.
    if(Trigger.isAfter && Trigger.isUpdate){
        
        // Calling Handler class Update method.
        FinancialsRollupSummaryHandlerCls.updateFinancials((List<Financials__c>)Trigger.old);
    }

}
Trigger Handler Class
--------------------------------
public class FinancialsRollupSummaryHandlerCls {
    
    Public static String recordYear = 'FY-2016';
    Public static Decimal grsum ;
    Public static Decimal gesum ;
    Public static Decimal amsgrsum ;
    Public static Decimal amsgesum ;
    
    // Static method for insert Financial records
    public static void insertFinancials(List<Financials__c> newrecs){
        
        List<Account> updateAccs = new List<Account>();
        Set<Id> accIds = new Set<Id>();
        
        for(Financials__c fin : newrecs){
            
            if(fin.AccountName__c != null){
                accIds.add(fin.AccountName__c);
            }
        }
        
        if(accIds.size() > 0){
            
            for(Account acc : [Select id,name,RS_Global_EBITDA_Sum__c,RS_Global_Revenue_Sum__c,RS_AMS_Global_Revenue_Sum__c,RS_AMS_Global_EBITDA_B4_Sum__c,
                              (Select id,Global_Revenue_Total__c,Global_EBITDA_B4_Total__c,AMS_Global_Rev__c,AMS_Global_EBITDA_B4__c,Year__c from Financial__r) 
                               from Account where Id In :accIds]){
                                   
                                   for(AggregateResult ag : [Select sum(Global_Revenue_Total__c)rev,sum(Global_EBITDA_B4_Total__c)ebsum,sum(AMS_Global_Rev__c)amsrev,sum(AMS_Global_EBITDA_B4__c)amsgesum from Financials__c where AccountName__c =: acc.id and Year__c=: recordYear]){
                                                                 
                                                                 grsum = (Decimal)ag.get('rev');
                                                                 gesum = (Decimal)ag.get('ebsum');
                                                                 amsgrsum = (Decimal)ag.get('amsrev');
                                                                 amsgesum = (Decimal)ag.get('amsgesum');
                                                             }
                                   acc.RS_Global_Revenue_Sum__c = grsum;
                                   acc.RS_Global_EBITDA_Sum__c = gesum;
                                   acc.RS_AMS_Global_Revenue_Sum__c = amsgrsum;
                                   acc.RS_AMS_Global_EBITDA_B4_Sum__c = amsgesum;
                                   
                                   
                                   updateAccs.add(acc);
                               }
            update updateAccs;
        }
    
    }
    
    // Static method for delete financial records
    public static void deleteFinancials(List<Financials__c> delrecs){
        
               
        List<Account> updateAccs = new List<Account>();
        Set<Id> accIds = new Set<Id>();
        
        for(Financials__c fin : delrecs){
            
            if(fin.AccountName__c != null){
                accIds.add(fin.AccountName__c);
            }
        }
        
        if(accIds.size() > 0){
            
            for(Account acc : [Select id,name,RS_Global_EBITDA_Sum__c,RS_Global_Revenue_Sum__c,RS_AMS_Global_Revenue_Sum__c,RS_AMS_Global_EBITDA_B4_Sum__c,
                              (Select id,Global_Revenue_Total__c,Global_EBITDA_B4_Total__c,AMS_Global_Rev__c,AMS_Global_EBITDA_B4__c,Year__c from Financial__r) 
                               from Account where Id In :accIds]){
                                   
                                   for(AggregateResult ag : [Select sum(Global_Revenue_Total__c)rev,sum(Global_EBITDA_B4_Total__c)ebsum,sum(AMS_Global_Rev__c)amsrev,sum(AMS_Global_EBITDA_B4__c)amsgesum from Financials__c where AccountName__c =: acc.id and Year__c=: recordYear]){
                                                                 
                                                                 grsum = (Decimal)ag.get('rev');
                                                                 gesum = (Decimal)ag.get('ebsum');
                                                                 amsgrsum = (Decimal)ag.get('amsrev');
                                                                 amsgesum = (Decimal)ag.get('amsgesum');
                                                             }
                                   acc.RS_Global_Revenue_Sum__c = grsum;
                                   acc.RS_Global_EBITDA_Sum__c = gesum;
                                   acc.RS_AMS_Global_Revenue_Sum__c = amsgrsum;
                                   acc.RS_AMS_Global_EBITDA_B4_Sum__c = amsgesum;
                                   
                                   
                                   updateAccs.add(acc);
                               }
            update updateAccs;
        }
    
    }
    
    // Static method for update Financial records.
    public static void updateFinancials(List<Financials__c> updaterecs){
        
               
        List<Account> updateAccs = new List<Account>();
        Set<Id> accIds = new Set<Id>();
        
        for(Financials__c fin : updaterecs){
            
            if(fin.AccountName__c != null){
                accIds.add(fin.AccountName__c);
            }
        }
        
        if(accIds.size() > 0){
            
            for(Account acc : [Select id,name,RS_Global_EBITDA_Sum__c,RS_Global_Revenue_Sum__c,RS_AMS_Global_Revenue_Sum__c,RS_AMS_Global_EBITDA_B4_Sum__c,
                              (Select id,Global_Revenue_Total__c,Global_EBITDA_B4_Total__c,AMS_Global_Rev__c,AMS_Global_EBITDA_B4__c,Year__c from Financial__r) 
                               from Account where Id In :accIds]){
                                   
                                   for(AggregateResult ag : [Select sum(Global_Revenue_Total__c)rev,sum(Global_EBITDA_B4_Total__c)ebsum,sum(AMS_Global_Rev__c)amsrev,sum(AMS_Global_EBITDA_B4__c)amsgesum from Financials__c where AccountName__c =: acc.id and Year__c=: recordYear]){
                                                                 
                                                                 grsum = (Decimal)ag.get('rev');
                                                                 gesum = (Decimal)ag.get('ebsum');
                                                                 amsgrsum = (Decimal)ag.get('amsrev');
                                                                 amsgesum = (Decimal)ag.get('amsgesum');
                                                             }
                                   acc.RS_Global_Revenue_Sum__c = grsum;
                                   acc.RS_Global_EBITDA_Sum__c = gesum;
                                   acc.RS_AMS_Global_Revenue_Sum__c = amsgrsum;
                                   acc.RS_AMS_Global_EBITDA_B4_Sum__c = amsgesum;
                                   
                                   
                                   updateAccs.add(acc);
                               }
            update updateAccs;
        }
    
    }
Can anyone let me know how to do this using Map?

Regards
Lakshmi

 
Hi Team,

How can we simplify below formula.

OR(AND(OR(ISPICKVAL(Region__c,"West"),ISPICKVAL(Region__c,"North"),ISPICKVAL(Region__c,"South"),ISPICKVAL(Region__c,"East"),ISPICKVAL(Region__c,"Northeast"),ISPICKVAL(Region__c,"Latin America")),Annualized_EBITDA__c >=1500000),AND(OR(ISPICKVAL(Region__c,"A&T AMS"),ISPICKVAL(Region__c,"A&T APAC"),ISPICKVAL(Region__c,"A&T EMEA"),ISPICKVAL(Region__c,"APAC"),ISPICKVAL(Region__c,"Competitors"),ISPICKVAL(Region__c,"DCS"),ISPICKVAL(Region__c,"EMEA"),ISPICKVAL(Region__c,"Govt & PS"),ISPICKVAL(Region__c,"Healthcare"),ISPICKVAL(Region__c,"I&M"),ISPICKVAL(Region__c,"Life Sciences"),ISPICKVAL(Region__c,"LFM")),Annualized_EBITDA__c >=1000000),AND(OR(ISPICKVAL(StageName,"Win (Contract Signed)"),ISPICKVAL(StageName,"Lost Accounts"),ISPICKVAL(StageName,"Lost Pursuits"),ISPICKVAL(StageName,"On Hold"),ISPICKVAL(StageName,"Dead"),ISPICKVAL(StageName,"Declined")),!ISPICKVAL(Win_Loss_Year__c ,"2018"),Annualized_EBITDA__c >=1000000))


Regards
Lakshmi
Hi Team,

How to validate the fields in Flow?
1. validation profile or user ( Make it madatory based on profile)
2. How to validate blank or null values (for text)

Can someone let me know how I can do this?

Regards
Lakshmi
Hi Team,

What are the uses and how to reduce the code using map in Salesforce?
Give me some scenarios about Map (When & Where we have to use Map in Coding)?


Regards
Lakshmi
Hi Team,

How can we attach the event to a new opportunity?

Regards
Lakshmi
Hi Team,

After delete & update code not covered in trigger. please give me any idea about this requirement.

Trigger:
----------
trigger FinancialsCountTrigger on Financials__c (after insert, after update, after delete, after undelete) {
    
    if(checkRecursive.runOnce()){
        
        List<Account> updateAcc = new List<Account>();
        Set<Id> accid = new Set<Id>();
        
        Decimal totalRevenue;
        Decimal totalEBITDA;
        
        if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete)){
            for(Financials__c fin : Trigger.New){
                if(fin.AccountName__c != null){
                    accid.add(fin.AccountName__c);
                }
            }
        }
        
        if(Trigger.isAfter && (Trigger.isUpdate || Trigger.isDelete)){
            for(Financials__c fin : Trigger.Old){
                if(fin.AccountName__c != null){
                    accid.add(fin.AccountName__c);
                    //system.debug('-----'+accid);
                }
            }
        }
        
            if(accid.size() > 0){
            List<Account> acclist = [select id,Name,Global_Revenue_Total__c,Global_EBITDA_B4_Total__c,
                                     (select id,Global_Revenue_Total__c,Global_EBITDA_B4_Total__c from Financial__r) from Account where id in :accid];
            
            for(Account acc : acclist){
                
                
                List<AggregateResult> aggres = [Select sum(Global_Revenue_Total__c)revtot,sum(Global_EBITDA_B4_Total__c)ebitdatot
                                                from Financials__c where AccountName__c=:acc.id and Year__c='FY-2017'];
                for(AggregateResult ag : aggres){
                    totalRevenue = (Decimal)ag.get('revtot');
                    totalEBITDA = (Decimal)ag.get('ebitdatot');
                }
                acc.Global_Revenue_Total__c = totalRevenue;
                acc.Global_EBITDA_B4_Total__c = totalEBITDA;
                updateAcc.add(acc);
            }
          }
          update updateAcc;
        
    }
    
}
Test Class
-----------------
@isTest
public class TestFinancialsCountTrigger {
    
    public static testMethod void financialCount(){
        
        Account acc = new Account(Name='3M Corporation',Industry='Conglomerate');
        insert acc;
        
        Account acc2 = new Account(Name='3M Corporation2',Industry='Conglomerate');
        insert acc2;
        
        Financials__c fin = new Financials__c(AccountName__c=acc.id,Name='Test',Year__c='FY-2017',Global_Revenue_Total__c=100,Global_EBITDA_Total__c=200);
        insert fin;
        
        Financials__c fin2 = new Financials__c(AccountName__c=acc2.id,Name='Test2',Year__c='FY-2017',Global_Revenue_Total__c=500,Global_EBITDA_Total__c=400);
        insert fin2;
        
        fin.Global_Revenue_Total__c = 500;
        update fin;
        delete fin;
                
        Test.startTest();
        
        List<Financials__c> finlist = [select id from Financials__c where AccountName__c = :acc.Id and Year__c='FY-2017'];
        delete finlist;
        
        Test.stopTest();
        
        
    }

}
Please give me reply any one......

Regards
Lakshmi

 
Hi Team,


1. Write a test class for Rollup Summary Trigger , must cover 100% code coverage?
2. Without writing Test class shall we deploy the Trigger from Sandbox to Produntion. Explain?

Trigger Code :
 
trigger RolllupSummaryOppAmt on Opportunity (After insert, After update,After delete, After undelete) {
    if(checkRecursive.runOnce()){
    Set<Id> accid = new Set<Id>();
    Decimal avgamt;
    Decimal sumamt;
        Integer noopp;
    if(Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete){
        for(Opportunity opp : Trigger.New){
            if(opp.AccountId != null){
                accid.add(opp.AccountId);
            }
            
        }
    }
    
    if(Trigger.isDelete || Trigger.isUpdate){
        for(Opportunity op : Trigger.Old){
            if(op.AccountId != null){
                accid.add(op.AccountId);
            }
            
        }
    }
        
    List<Account> aclist = [select id,OppAvgAmount__c,SumOfOppAmt__c,NoOfOpp__c,(select id,amount from opportunities) from account where id In :accid];
    List<Account> upacc = new List<Account>();
    if(aclist.size()>0){
        for(Account ac : aclist){
           
            List<AggregateResult> aglist = [select count(id)t,avg(amount)agg,min(amount)sumamt from opportunity where accountid = :ac.id];
            for(AggregateResult ag : aglist){
                avgamt = (Decimal)ag.get('agg');
                sumamt = (Decimal)ag.get('sumamt');
                noopp = (Integer)ag.get('t');
                system.debug('---average---:'+avgamt);
            }
            ac.OppAvgAmount__c = avgamt;
            ac.SumOfOppAmt__c = sumamt;
            ac.NoOfOpp__c = noopp;
            upacc.add(ac);
        }
        
            update upacc;
       
    }

    }
}


Thanks
Lakshmi.
Hi Team,

Q). What are the issues or errors we are facing at the time of writing  visualforce pages and apex classes?
Kindly reply to this post .......

Regards
Lakshmi
Hi Team,


Can any one please tell me the challenges facing in Salesforce Administration?


Thanks & Regards
Lakshmi
Hi Team,


What are the challenges facing in apex code development ?


Thanks & Regards
Lakshmi.
Hi Team,

What are the challenges we are facimg in deployment using ANT migration tool?


Thanks & Regards
Lakshmi
Hi All,

Q). One object (s1) & 3 tasks (t1, t2, t3) are there. Each task performing discount related stuff.
   Write a trigger that should calculate the sum of 3 tasks.  And if any task is modified than trigger should fire automatically & perform the same.


Can any one reply for this post..
Thanks in advance
 
Hi All,

Q). what is the difference between actionFunction and actionSupport, Explain with funcionality?

can anyone reply for this post...
Thanks in advance..
Hi All,

Q). 3 users with same profile (R/W permissions), need to remove Read permission for one user, how can we achieve that?

Can anyone reply for this post...
Thanks in advance.
Hi All,

Q). What is a future method ? When we are going to use Future methods? Example program for Future method and Schedulable class for Future method?

Give me reply anyone.....
HI All,

Q). What is a Batch Apex,Queueable Apex and @Future methods?, What are the differences between them and when we are going to use these classes?
Can anyone explain these classes.......
 
Hi Team,

Requirement : Calculating sum and  count using Trigger. We have to calculate for 20 fields in child object.
1. For each field we have to check condition  : year, accountname(parent id) and field value.
2. For this i am using aggregate result function individually, because of that i am getting soql query exception.
SOQL Query Exception : AggregateResult caused too many rows exception?
Trigger:
------------
trigger KingsleyRollupSummaryTrig on KingsleyTranscript__c (after insert, after Update, after delete, after undelete) {
    
    /*
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUndelete)){
        KingsleyRollupSummaryTrigHandlerCls.insertRecords((List<KingsleyTranscript__c>)Trigger.New);
    }
    
    if(Trigger.isAfter && Trigger.isUpdate){
        //KingsleyRollupSummaryTrigHandlerCls.updateRecords((List<KingsleyTranscript__c>)Trigger.old);
    }
    
    if(Trigger.isAfter && Trigger.isDelete){
       // KingsleyRollupSummaryTrigHandlerCls.deleteRecords((List<KingsleyTranscript__c>)Trigger.old);
    }
*/
    String recordYear = '2017';
      Decimal amsum ;
      Integer amcount ;
      Decimal emeasum ;
      Integer emeacount ;
      Decimal apacsum ;
      Integer apaccount ;
      Decimal osrsum ;
      Integer osrcount ;
      Decimal vcrsum ;
      Integer vcrcount ;
      Decimal adorsum ;
      Integer adorcount ;
      Decimal tmpaorsum ;
      Integer tmpaorcount ;
      Decimal tmlrsum ;
      Integer tmlrcount ;
	  Decimal tmpa_off_acct_sum ;
      Integer tmpa_off_acct_count ;
      Decimal fm_or_sum ;
      Integer fm_or_count ;
      Decimal fm_lr_sum ;
      Integer fm_lr_count ;
      Decimal fm_off_acct_lr_sum ;
      Integer fm_off_acct_lr_count ;
      Decimal pjm_off_acct_lr_sum ;
      Integer pjm_off_acct_lr_count ;
      Decimal pjm_or_sum ;
      Integer pjm_or_count ;
      Decimal pjm_lr_sum ;
      Integer pjm_lr_count ;
      Decimal remc_or_sum ;
      Integer remc_or_count ;
      Decimal off_acct_remc_sum ;
      Integer off_acct_remc_count ;
      Decimal thought_lp_sum ;
      Integer thought_lp_count ;
      Decimal exec_or_sum ;
      Integer exec_or_count ;
      Decimal peer_nps_sum ;
      Integer peer_nps_count ;

        
      List<Account> updateAccs = new List<Account>();
      Set<Id> accIds = new Set<Id>();
      
    
    
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete)){
        
        
        for(KingsleyTranscript__c kt : Trigger.New){
            
            if(kt.Account_Name__c != null){
                accIds.add(kt.Account_Name__c);
            }
        }
    }
    
    if(Trigger.isAfter && (Trigger.isUpdate || Trigger.isDelete)){
        
        
        for(KingsleyTranscript__c kt : Trigger.New){
            
            if(kt.Account_Name__c != null){
                accIds.add(kt.Account_Name__c);
            }
        }
    }
    
   
        
        if(accIds.size() > 0){
            List<Account> acclist = [Select id,name,RS_Reg_Client_Satisfaction_Ams_Sum__c,RS_Reg_Client_Satisfaction_Ams_Count__c,RS_Reg_Client_Satisfaction_EMEA_Sum__c,
                               RS_Reg_Client_Satisfaction_EMEA_Count__c,RS_Reg_Client_Satisfaction_APAC_Sum__c,RS_Reg_Client_Satisfaction_APAC_Count__c,
                               RS_Overall_Satisfaction_Rating_Sum__c,RS_Overall_Satisfaction_Rating_Count__c,RS_Value_Contribution_Rating_Sum__c,
                               RS_Value_Contribution_Rating_Count__c,RS_AD_Overall_Rating_Sum__c,RS_AD_Overall_Rating_Count__c,RS_TM_PA_Overall_Rating_Sum__c,
                               RS_TM_PA_Overall_Rating_Count__c,RS_TM_Leader_Rating_Sum__c,RS_TM_Leader_Rating_Count__c,RS_TM_PA_Off_Acct_Leader_Rating_Sum__c,
                               RS_TM_PA_Off_Acct_Leader_Rating_Count__c,RS_FM_Overall_Rating_Sum__c,RS_FM_Overall_Rating_Count__c,RS_FM_Leader_Rating_Sum__c,
                               RS_FM_Leader_Rating_Count__c,RS_FM_Off_Acct_Leadership_Rating_Sum__c,RS_FM_Off_Acct_Leadership_Rating_Count__c,RS_PJM_Overall_Rating_Sum__c,
                               RS_PJM_Overall_Rating_Count__c,RS_PJM_Leader_Rating_Sum__c,RS_PJM_Leader_Rating_Count__c,RS_PJM_Off_Acct_Leadership_Rating_Sum__c,
                               RS_PJM_Off_Acct_Leadership_Rating_Count__c,RS_REMC_Overall_Rating_Sum__c,RS_REMC_Overall_Rating_Count__c,RS_Off_Acct_REMC_Leader_Rating_Sum__c,
                               RS_Off_Acct_REMC_Leader_Rating_Count__c,RS_Thought_Leadership_progs_Rating_Sum__c,RS_Thought_Leadership_prog_Rating_Count__c,
                               RS_Exec_Leadership_Overall_Rating_Sum__c,RS_Exec_Leadership_Overall_Rating_Count__c,RS_Peer_Recommendation_NPS_Rating_Sum__c,RS_Peer_Recommend_NPS_Rating_Count__c,
                               (Select id,Regional_Client_Satisfaction_Americas__c,Regional_Client_Satisfaction_EMEA__c,Regional_Client_Satisfaction_APAC__c,
                                Overall_satisfaction_Rating__c,Value_Contribution_Rating__c,Additional_Vakue_Focus_Areas__c,AD_Overall_Rating__c,
                                TM_PA_Overall_Rating__c,TM_Leader_Rating__c,TM_PA_Off_Account_Leader_Rating__c,FM_Overall_Rating__c,FM_Leader_Rating__c,
                                FM_Off_Acct_Lship_Rating__c,PJM_Overall_Rating__c,PJM_Leader_Rating__c,PJM_Off_Acct_Leadership_Rating__c,REMC_Overall_Rating__c,
                                Off_Account_REMC_Leader_Rating__c,Thought_Ldrship_Pgm_Rating__c,Exec_Ldrship_Overall_Rating__c,Peer_Recomend_NPS_Rating__c,
                                Recorded_Year__c from Kingsley_Transcript__r) from Account where Id In :accIds];
            
            for(Account acc : acclist){
                                   
                // for 'Regional_Client_Satisfaction_Americas__c' field value calculation
                AggregateResult[] agres = [Select SUM(Regional_Client_Satisfaction_Americas__c)amsum,COUNT(Regional_Client_Satisfaction_Americas__c)amcount 
                                   	            from KingsleyTranscript__c where Account_Name__c =: acc.id and Regional_Client_Satisfaction_Americas__c > 0 and Recorded_Year__c=: recordYear];
                
                
                if(agres.size() > 0){
                    
                     for(AggregateResult ag : agres){
                                                                 
                          amsum = (Decimal)ag.get('amsum');
                          amcount = (Integer)ag.get('amcount');
                      }
                      acc.RS_Reg_Client_Satisfaction_Ams_Sum__c = amsum;
                      acc.RS_Reg_Client_Satisfaction_Ams_Count__c = amcount;
                    
                }
               // for 'Regional_Client_Satisfaction_EMEA__c' field value calculation
                AggregateResult[] agres2 = [Select SUM(Regional_Client_Satisfaction_EMEA__c)emeasum,COUNT(Regional_Client_Satisfaction_EMEA__c)emeacount 
                                               from KingsleyTranscript__c where Account_Name__c =: acc.id and Regional_Client_Satisfaction_EMEA__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres2.size() > 0){
                    
                    for(AggregateResult ag : agres2){
                                                                 
                                                                 emeasum = (Decimal)ag.get('emeasum');
                                                                 emeacount = (Integer)ag.get('emeacount');
                                                                 
                                                             }
                                   acc.RS_Reg_Client_Satisfaction_EMEA_Sum__c = emeasum;
                                   acc.RS_Reg_Client_Satisfaction_EMEA_Count__c = emeacount;
                    
                }               
                                   // for 'Regional_Client_Satisfaction_APAC__c' field value calculation
                AggregateResult[] agres3 = [Select SUM(Regional_Client_Satisfaction_APAC__c)apacsum,COUNT(Regional_Client_Satisfaction_APAC__c)apaccount 
                                                from KingsleyTranscript__c where Account_Name__c =: acc.id and Regional_Client_Satisfaction_APAC__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres3.size() > 0){
                    for(AggregateResult ag : agres3){
                                                                 
                                                                 apacsum = (Decimal)ag.get('apacsum');
                                                                 apaccount = (Integer)ag.get('apaccount');
                                                                 
                                                             }
                                   acc.RS_Reg_Client_Satisfaction_APAC_Sum__c = apacsum;
                                   acc.RS_Reg_Client_Satisfaction_APAC_Count__c = apaccount;
             
                }
            
                                    
                                   // for 'Overall_satisfaction_Rating__c' field value calculation
                AggregateResult[] agres4 = [Select SUM(Overall_satisfaction_Rating__c)osrsum,COUNT(Overall_satisfaction_Rating__c)osrcount 
                                                from KingsleyTranscript__c where Account_Name__c =: acc.id and Overall_satisfaction_Rating__c > 0 and Recorded_Year__c=: recordYear];                 
                
                if(agres4.size() > 0){
                    for(AggregateResult ag : agres4){
                                                                 
                                                                 osrsum = (Decimal)ag.get('osrsum');
                                                                 osrcount = (Integer)ag.get('osrcount');
                                                                 
                                                             }
                                   acc.RS_Overall_Satisfaction_Rating_Sum__c = osrsum;
                                   acc.RS_Overall_Satisfaction_Rating_Count__c = osrcount;

                }
                				   // for 'Value_Contribution_Rating__c' field value calculation
                AggregateResult[] agres5 = [Select SUM(Value_Contribution_Rating__c)vcrsum,COUNT(Value_Contribution_Rating__c)vcrcount from KingsleyTranscript__c where Account_Name__c =: acc.id and Value_Contribution_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                
                if(agres5.size() > 0){
                    for(AggregateResult ag : agres5){
                                                                 
                                                                 vcrsum = (Decimal)ag.get('vcrsum');
                                                                 vcrcount = (Integer)ag.get('vcrcount');
                                                                 
                                                             }
                                   acc.RS_Value_Contribution_Rating_Sum__c = vcrsum;
                                   acc.RS_Value_Contribution_Rating_Count__c = vcrcount;

                }
               
                                   // for 'AD_Overall_Rating__c' field value calculation
                AggregateResult[] agres6 = [Select SUM(AD_Overall_Rating__c)adorsum,COUNT(AD_Overall_Rating__c)adorcount from KingsleyTranscript__c where Account_Name__c =: acc.id and AD_Overall_Rating__c > 0 and Recorded_Year__c=: recordYear];                  
                if(agres6.size() > 0){
                    for(AggregateResult ag : agres6){
                                                                 
                                                                 adorsum = (Decimal)ag.get('adorsum');
                                                                 adorcount = (Integer)ag.get('adorcount');
                                                                 
                                                             }
                                   acc.RS_AD_Overall_Rating_Sum__c = adorsum;
                                   acc.RS_AD_Overall_Rating_Count__c = adorcount;

                }                                   
                                   
 								   // for 'TM_PA_Overall_Rating__c' field value calculation
                AggregateResult[] agres7 = [Select SUM(TM_PA_Overall_Rating__c)tmpaorsum,COUNT(TM_PA_Overall_Rating__c)tmpaorcount 
                                                from KingsleyTranscript__c where Account_Name__c =: acc.id and TM_PA_Overall_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres7.size() > 0){
                    for(AggregateResult ag : agres7){
                                                                 
                                                                 tmpaorsum = (Decimal)ag.get('tmpaorsum');
                                                                 tmpaorcount = (Integer)ag.get('tmpaorcount');
                                                                 
                                                             }
                                   acc.RS_TM_PA_Overall_Rating_Sum__c = tmpaorsum;
                                   acc.RS_TM_PA_Overall_Rating_Count__c = tmpaorcount;

                }

 							       // for 'TM_Leader_Rating__c' field value calculation
                AggregateResult[] agres8 = [Select SUM(TM_Leader_Rating__c)tmlrsum,COUNT(TM_Leader_Rating__c)tmlrcount 
                                                from KingsleyTranscript__c where Account_Name__c =: acc.id and TM_Leader_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                
                if(agres8.size() > 0){
                    for(AggregateResult ag : agres8){
                                                                 
                                                                 tmlrsum = (Decimal)ag.get('tmlrsum');
                                                                 tmlrcount = (Integer)ag.get('tmlrcount');
                                                                 
                                                             }
                                   acc.RS_TM_Leader_Rating_Sum__c = tmlrsum;
                                   acc.RS_TM_Leader_Rating_Count__c = tmlrcount;

                }

								 // for 'TM_PA_Off_Account_Leader_Rating__c' field value calculation
                AggregateResult[] agres9 = [Select SUM(TM_PA_Off_Account_Leader_Rating__c)tmpa_off_acct_sum,COUNT(TM_PA_Off_Account_Leader_Rating__c)tmpa_off_acct_count 
                                                from KingsleyTranscript__c where Account_Name__c =: acc.id and TM_PA_Off_Account_Leader_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres9.size() > 0){
                    for(AggregateResult ag :agres9 ){
                                                                 
                                                                 tmpa_off_acct_sum = (Decimal)ag.get('tmpa_off_acct_sum');
                                                                 tmpa_off_acct_count = (Integer)ag.get('tmpa_off_acct_count');
                                                                 
                                                             }
                                   acc.RS_TM_PA_Off_Acct_Leader_Rating_Sum__c = tmpa_off_acct_sum;
                                   acc.RS_TM_PA_Off_Acct_Leader_Rating_Count__c = tmpa_off_acct_count;

                }                                    
                                    // for 'FM_Overall_Rating__c' field value calculation
                AggregateResult[] agres10 = [Select SUM(FM_Overall_Rating__c)fm_or_sum,COUNT(FM_Overall_Rating__c)fm_or_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and FM_Overall_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres10.size() > 0){
                    for(AggregateResult ag : agres10){
                                                                 
                                                                 fm_or_sum = (Decimal)ag.get('fm_or_sum');
                                                                 fm_or_count = (Integer)ag.get('fm_or_count');
                                                                 
                                                             }
                                   acc.RS_FM_Overall_Rating_Sum__c = fm_or_sum;
                                   acc.RS_FM_Overall_Rating_Count__c = fm_or_count;

                }
 								// for 'FM_Leader_Rating__c' field value calculation
                                   
                AggregateResult[] agres11 = [Select SUM(FM_Leader_Rating__c)fm_lr_sum,COUNT(FM_Leader_Rating__c)fm_lr_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and FM_Leader_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres11.size() > 0){
                    for(AggregateResult ag : agres11){
                                                                 
                                                                 fm_lr_sum = (Decimal)ag.get('fm_lr_sum');
                                                                 fm_lr_count = (Integer)ag.get('fm_lr_count');
                                                                 
                                                             }
                                   acc.RS_FM_Leader_Rating_Sum__c = fm_lr_sum;
                                   acc.RS_FM_Leader_Rating_Count__c = fm_lr_count;

                }
								 // for 'FM_Off_Acct_Lship_Rating__c' field value calculation
                AggregateResult[] agres12 = [Select SUM(FM_Off_Acct_Lship_Rating__c)fm_off_acct_lr_sum,COUNT(FM_Off_Acct_Lship_Rating__c)fm_off_acct_lr_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and FM_Off_Acct_Lship_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres12.size() >0){
                    for(AggregateResult ag : agres12){
                                                                 
                                                                 fm_off_acct_lr_sum = (Decimal)ag.get('fm_off_acct_lr_sum');
                                                                 fm_off_acct_lr_count = (Integer)ag.get('fm_off_acct_lr_count');
                                                                 
                                                             }
                                   acc.RS_FM_Off_Acct_Leadership_Rating_Sum__c = fm_off_acct_lr_sum;
                                   acc.RS_FM_Off_Acct_Leadership_Rating_Count__c = fm_off_acct_lr_count;

                }                                    
                                    
                                    // for 'PJM_Overall_Rating__c' field value calculation
                AggregateResult[] agres13 = [Select SUM(PJM_Overall_Rating__c)pjm_or_sum,COUNT(PJM_Overall_Rating__c)pjm_or_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and PJM_Overall_Rating__c > 0 and Recorded_Year__c=: recordYear];                   
                if(agres13.size() > 0){
                    for(AggregateResult ag : agres13){
                                                                 
                                                                 pjm_or_sum = (Decimal)ag.get('pjm_or_sum');
                                                                 pjm_or_count = (Integer)ag.get('pjm_or_count');
                                                                 
                                                             }
                                   acc.RS_PJM_Overall_Rating_Sum__c = pjm_or_sum;
                                   acc.RS_PJM_Overall_Rating_Count__c = pjm_or_count;

                }
 								// for 'PJM_Leader_Rating__c' field value calculation
                AggregateResult[] agres14 = [Select SUM(PJM_Leader_Rating__c)pjm_lr_sum,COUNT(PJM_Leader_Rating__c)pjm_lr_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and PJM_Leader_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres14.size()>0){
                    for(AggregateResult ag : agres14){
                                                                 
                                                                 pjm_lr_sum = (Decimal)ag.get('pjm_lr_sum');
                                                                 pjm_lr_count = (Integer)ag.get('pjm_lr_count');
                                                                 
                                                             }
                                   acc.RS_PJM_Leader_Rating_Sum__c = pjm_lr_sum;
                                   acc.RS_PJM_Leader_Rating_Count__c = pjm_lr_count;

                }
                
								 // for 'PJM_Off_Acct_Leadership_Rating__c field value calculation
	             AggregateResult[] agres15 = [Select SUM(PJM_Off_Acct_Leadership_Rating__c)pjm_off_acct_lr_sum,COUNT(PJM_Off_Acct_Leadership_Rating__c)pjm_off_acct_lr_count 
                                                  from KingsleyTranscript__c where Account_Name__c =: acc.id and PJM_Off_Acct_Leadership_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres15.size() > 0){
                    for(AggregateResult ag : agres15){
                                                                 
                                                                 pjm_off_acct_lr_sum = (Decimal)ag.get('pjm_off_acct_lr_sum');
                                                                 pjm_off_acct_lr_count = (Integer)ag.get('pjm_off_acct_lr_count');
                                                                 
                                                             }
                                   acc.RS_PJM_Off_Acct_Leadership_Rating_Sum__c = pjm_off_acct_lr_sum;
                                   acc.RS_PJM_Off_Acct_Leadership_Rating_Count__c = pjm_off_acct_lr_count;
                                   
                }
                                    
                                    // for 'REMC_Overall_Rating__c' field value calculation
                 AggregateResult[] agres16 = [Select SUM(REMC_Overall_Rating__c)remc_or_sum,COUNT(REMC_Overall_Rating__c)remc_or_count
                                                  from KingsleyTranscript__c where Account_Name__c =: acc.id and REMC_Overall_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres16.size()>0){
                                   for(AggregateResult ag : agres16){
                                                                 
                                                                 remc_or_sum = (Decimal)ag.get('remc_or_sum');
                                                                 remc_or_count = (Integer)ag.get('remc_or_count');
                                                                 
                                                             }
                                   acc.RS_REMC_Overall_Rating_Sum__c = remc_or_sum;
                                   acc.RS_REMC_Overall_Rating_Count__c = remc_or_count;

                }
                    
 								// for 'Off_Account_REMC_Leader_Rating__c' field value calculation
 				AggregateResult[] agres17 = [Select SUM(Off_Account_REMC_Leader_Rating__c)off_acct_remc_sum,COUNT(Off_Account_REMC_Leader_Rating__c)off_acct_remc_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and Off_Account_REMC_Leader_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres17.size()>0){
                                   for(AggregateResult ag : agres17) {
                                                                 
                                                                 off_acct_remc_sum = (Decimal)ag.get('off_acct_remc_sum');
                                                                 off_acct_remc_count = (Integer)ag.get('off_acct_remc_count');
                                                                 
                                                             }
                                   acc.RS_Off_Acct_REMC_Leader_Rating_Sum__c = off_acct_remc_sum;
                                   acc.RS_Off_Acct_REMC_Leader_Rating_Count__c = off_acct_remc_count;

                }
                    
								 // for 'Thought_Ldrship_Pgm_Rating__c field value calculation
		        AggregateResult[] agres18 = [Select SUM(Thought_Ldrship_Pgm_Rating__c)thought_lp_sum,COUNT(Thought_Ldrship_Pgm_Rating__c)thought_lp_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and Thought_Ldrship_Pgm_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres18.size()>0){
                                   for(AggregateResult ag : agres18){
                                                                 
                                                                 thought_lp_sum = (Decimal)ag.get('thought_lp_sum');
                                                                 thought_lp_count = (Integer)ag.get('thought_lp_count');
                                                                 
                                                             }
                                   acc.RS_Thought_Leadership_progs_Rating_Sum__c = thought_lp_sum;
                                   acc.RS_Thought_Leadership_prog_Rating_Count__c = thought_lp_count;

                }
 								// for 'Exec_Ldrship_Overall_Rating__c' field value calculation
                AggregateResult[] agres19 = [Select SUM(Exec_Ldrship_Overall_Rating__c)exec_or_sum,COUNT(Exec_Ldrship_Overall_Rating__c)exec_or_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and Exec_Ldrship_Overall_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres19.size()>0){
                    for(AggregateResult ag : agres19){
                                                                 
                                                                 exec_or_sum = (Decimal)ag.get('exec_or_sum');
                                                                 exec_or_count = (Integer)ag.get('exec_or_count');
                                                                 
                                                             }
                                   acc.RS_Exec_Leadership_Overall_Rating_Sum__c = exec_or_sum;
                                   acc.RS_Exec_Leadership_Overall_Rating_Count__c = exec_or_count;
                }
 								// for 'Peer_Recomend_NPS_Rating__c' field value calculation
                AggregateResult[] agres20 = [Select SUM(Peer_Recomend_NPS_Rating__c)peer_nps_sum,COUNT(Peer_Recomend_NPS_Rating__c)peer_nps_count 
                                                 from KingsleyTranscript__c where Account_Name__c =: acc.id and Peer_Recomend_NPS_Rating__c > 0 and Recorded_Year__c=: recordYear];
                if(agres20.size()>0){
                    for(AggregateResult ag : agres20){
                                                                 
                                                                 peer_nps_sum = (Decimal)ag.get('peer_nps_sum');
                                                                 peer_nps_count = (Integer)ag.get('peer_nps_count');
                                                                 
                                                             }
                                   acc.RS_Peer_Recommendation_NPS_Rating_Sum__c = peer_nps_sum;
                                   acc.RS_Peer_Recommend_NPS_Rating_Count__c = peer_nps_count;               
                }
                                   updateAccs.add(acc);
            }         
               Database.update(updateAccs,false);   
        }   
}
Can any one let me know how to solve this problem?

Regards
Lakshmi S
 
Hi Team,

How can we simplify below formula.

OR(AND(OR(ISPICKVAL(Region__c,"West"),ISPICKVAL(Region__c,"North"),ISPICKVAL(Region__c,"South"),ISPICKVAL(Region__c,"East"),ISPICKVAL(Region__c,"Northeast"),ISPICKVAL(Region__c,"Latin America")),Annualized_EBITDA__c >=1500000),AND(OR(ISPICKVAL(Region__c,"A&T AMS"),ISPICKVAL(Region__c,"A&T APAC"),ISPICKVAL(Region__c,"A&T EMEA"),ISPICKVAL(Region__c,"APAC"),ISPICKVAL(Region__c,"Competitors"),ISPICKVAL(Region__c,"DCS"),ISPICKVAL(Region__c,"EMEA"),ISPICKVAL(Region__c,"Govt & PS"),ISPICKVAL(Region__c,"Healthcare"),ISPICKVAL(Region__c,"I&M"),ISPICKVAL(Region__c,"Life Sciences"),ISPICKVAL(Region__c,"LFM")),Annualized_EBITDA__c >=1000000),AND(OR(ISPICKVAL(StageName,"Win (Contract Signed)"),ISPICKVAL(StageName,"Lost Accounts"),ISPICKVAL(StageName,"Lost Pursuits"),ISPICKVAL(StageName,"On Hold"),ISPICKVAL(StageName,"Dead"),ISPICKVAL(StageName,"Declined")),!ISPICKVAL(Win_Loss_Year__c ,"2018"),Annualized_EBITDA__c >=1000000))


Regards
Lakshmi
Hi Team,

How to validate the fields in Flow?
1. validation profile or user ( Make it madatory based on profile)
2. How to validate blank or null values (for text)

Can someone let me know how I can do this?

Regards
Lakshmi
Hi Team,

What are the uses and how to reduce the code using map in Salesforce?
Give me some scenarios about Map (When & Where we have to use Map in Coding)?


Regards
Lakshmi
Hi Team,

How can we attach the event to a new opportunity?

Regards
Lakshmi
Hi Team,

After delete & update code not covered in trigger. please give me any idea about this requirement.

Trigger:
----------
trigger FinancialsCountTrigger on Financials__c (after insert, after update, after delete, after undelete) {
    
    if(checkRecursive.runOnce()){
        
        List<Account> updateAcc = new List<Account>();
        Set<Id> accid = new Set<Id>();
        
        Decimal totalRevenue;
        Decimal totalEBITDA;
        
        if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete)){
            for(Financials__c fin : Trigger.New){
                if(fin.AccountName__c != null){
                    accid.add(fin.AccountName__c);
                }
            }
        }
        
        if(Trigger.isAfter && (Trigger.isUpdate || Trigger.isDelete)){
            for(Financials__c fin : Trigger.Old){
                if(fin.AccountName__c != null){
                    accid.add(fin.AccountName__c);
                    //system.debug('-----'+accid);
                }
            }
        }
        
            if(accid.size() > 0){
            List<Account> acclist = [select id,Name,Global_Revenue_Total__c,Global_EBITDA_B4_Total__c,
                                     (select id,Global_Revenue_Total__c,Global_EBITDA_B4_Total__c from Financial__r) from Account where id in :accid];
            
            for(Account acc : acclist){
                
                
                List<AggregateResult> aggres = [Select sum(Global_Revenue_Total__c)revtot,sum(Global_EBITDA_B4_Total__c)ebitdatot
                                                from Financials__c where AccountName__c=:acc.id and Year__c='FY-2017'];
                for(AggregateResult ag : aggres){
                    totalRevenue = (Decimal)ag.get('revtot');
                    totalEBITDA = (Decimal)ag.get('ebitdatot');
                }
                acc.Global_Revenue_Total__c = totalRevenue;
                acc.Global_EBITDA_B4_Total__c = totalEBITDA;
                updateAcc.add(acc);
            }
          }
          update updateAcc;
        
    }
    
}
Test Class
-----------------
@isTest
public class TestFinancialsCountTrigger {
    
    public static testMethod void financialCount(){
        
        Account acc = new Account(Name='3M Corporation',Industry='Conglomerate');
        insert acc;
        
        Account acc2 = new Account(Name='3M Corporation2',Industry='Conglomerate');
        insert acc2;
        
        Financials__c fin = new Financials__c(AccountName__c=acc.id,Name='Test',Year__c='FY-2017',Global_Revenue_Total__c=100,Global_EBITDA_Total__c=200);
        insert fin;
        
        Financials__c fin2 = new Financials__c(AccountName__c=acc2.id,Name='Test2',Year__c='FY-2017',Global_Revenue_Total__c=500,Global_EBITDA_Total__c=400);
        insert fin2;
        
        fin.Global_Revenue_Total__c = 500;
        update fin;
        delete fin;
                
        Test.startTest();
        
        List<Financials__c> finlist = [select id from Financials__c where AccountName__c = :acc.Id and Year__c='FY-2017'];
        delete finlist;
        
        Test.stopTest();
        
        
    }

}
Please give me reply any one......

Regards
Lakshmi

 
Hi Team,


1. Write a test class for Rollup Summary Trigger , must cover 100% code coverage?
2. Without writing Test class shall we deploy the Trigger from Sandbox to Produntion. Explain?

Trigger Code :
 
trigger RolllupSummaryOppAmt on Opportunity (After insert, After update,After delete, After undelete) {
    if(checkRecursive.runOnce()){
    Set<Id> accid = new Set<Id>();
    Decimal avgamt;
    Decimal sumamt;
        Integer noopp;
    if(Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete){
        for(Opportunity opp : Trigger.New){
            if(opp.AccountId != null){
                accid.add(opp.AccountId);
            }
            
        }
    }
    
    if(Trigger.isDelete || Trigger.isUpdate){
        for(Opportunity op : Trigger.Old){
            if(op.AccountId != null){
                accid.add(op.AccountId);
            }
            
        }
    }
        
    List<Account> aclist = [select id,OppAvgAmount__c,SumOfOppAmt__c,NoOfOpp__c,(select id,amount from opportunities) from account where id In :accid];
    List<Account> upacc = new List<Account>();
    if(aclist.size()>0){
        for(Account ac : aclist){
           
            List<AggregateResult> aglist = [select count(id)t,avg(amount)agg,min(amount)sumamt from opportunity where accountid = :ac.id];
            for(AggregateResult ag : aglist){
                avgamt = (Decimal)ag.get('agg');
                sumamt = (Decimal)ag.get('sumamt');
                noopp = (Integer)ag.get('t');
                system.debug('---average---:'+avgamt);
            }
            ac.OppAvgAmount__c = avgamt;
            ac.SumOfOppAmt__c = sumamt;
            ac.NoOfOpp__c = noopp;
            upacc.add(ac);
        }
        
            update upacc;
       
    }

    }
}


Thanks
Lakshmi.
Hi Team,

Q). What are the issues or errors we are facing at the time of writing  visualforce pages and apex classes?
Kindly reply to this post .......

Regards
Lakshmi
Hi Team,


Can any one please tell me the challenges facing in Salesforce Administration?


Thanks & Regards
Lakshmi
Hi Team,


Write a batch class for to delete all contacts of accounts where Account field : active__c="yes" ?


Please give me the reply to above scenario....

Regards
Lakshmi