• JAYABALAJI TKM 1
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 11
    Replies
Hi 

I have a Java script values stored in name  "radArray" in visualforce page. How can I pass this values to get insert on clicking save button from below command button from visualforce page to class.

<apex:commandButton value="Save" action="{!save}">
When i change a pick list value this error is coming
Apex Class:
public with sharing class CreateWorkOrderRecord 
{
    /**
   * Create a new Work Order Record
   *
   * @param WorkOrder Work Order Work Order record to be inserted
   * 
   */
    @AuraEnabled
    public static String createRecord(WorkOrder workorder)
    {
        try
        {
            System.debug('CreateWorkOrderRecord::createRecord::workorder'+workorder);
            
            if(workorder!= null)
                insert workorder;
        } 
        catch (Exception ex)
        {
           ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,string.valueof(ex)));
             return null; 
        }
        return null; 
    } 
     @AuraEnabled
     public static List <String> getselectOptions(sObject objObject, string fld) 
     {
          List <String> allOpts = new list <String>();
          Schema.sObjectType objType = objObject.getSObjectType();  // Get the object type of the SObject.
          Schema.DescribeSObjectResult objDescribe = objType.getDescribe();  // Describe the SObject using its object type.
          Map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();  // Get a map of fields for the SObject
          List <Schema.PicklistEntry> values = fieldMap.get(fld).getDescribe().getPickListValues();  // Get the list of picklist values for this field.
        
          for(Schema.PicklistEntry a: values) 
           allOpts.add(a.getValue());  // Add these values to the selectoption list.
        
          allOpts.sort();
          return allOpts;
     }
           
}

Component:
<aura:component controller="CreateWorkOrderRecord" 
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" 
                access="global" >
    
    <!-- Include Static Resource-->
    <ltng:require styles="/resource/bootstrap1/css/bootstrap.min.css" 
                  scripts="/resource/bootstrap1/js/jquery.js,/resource/bootstrap/js/bootstrap.min.js"/>
    
    <!-- Define Attribute-->
    <aura:attribute name="selectedLookUpRecord" type="sObject" default="{}"/>
    <aura:attribute name="selectedLookUpRecord1" type="sObject" default="{}"/>
    <aura:attribute name="selectedLookUpRecord2" type="sObject" default="{}"/>
    <aura:attribute name="number" type="integer"/>
    <aura:attribute name="myText" type="String"/>

    <aura:attribute name="workorder" type="WorkOrder" default="{'sobjectType': 'WorkOrder',
                                                                  'Account__c': '',
                                                                  'Contact__c': '',
                                                                  'Opportunity__c': '', 
                                                                  'Priority': '',
                                                                  'StartDate': '',
                                                                  'Status': '',
                                                                     'Number_of_Weeks__c': '',
                                                                  'Visit_Frequency__c': '',
                                                               }"/><br/>
        <div>
            <table>
                <tr>
                    <td>
                        <h2 style="font-weight:bold;font-size:12px;margin-left:5%">New Work Order Edit</h2>
                        <h1 style="font-weight:bold;font-size:18px;margin-left:5%">New Work Order</h1>
                    </td>
                </tr>
            </table>
    </div><br/>
    <center>
        <div class="col-md-4 text-center">
              <lightning:button variant="brand" label="Save" onclick="{!c.create}"/>
        </div>
    </center><br/>
    <div class="slds-box" style="background:rgb(0, 161, 223);font-weight:bold;font-size:15pt;">
        <p>WorkOrder Information</p>
    </div>
    
    <div class="slds-grid slds-gutters">
        <div class="slds-col" style="width:500px;">
            <table class="slds-table slds-table--bordered slds-table--cell-buffer"> 
              <thead>
                 <tr>
                 <td width="45%">
                  <table>
                      <tr>
                        <td><c:customLookup objectAPIName="account" IconName="standard:account" label="Account" selectedRecord="{!v.selectedLookUpRecord}"/></td>
                    </tr>
                      <tr>
                        <td><c:customLookup objectAPIName="contact" IconName="standard:contact" label="Contact" selectedRecord="{!v.selectedLookUpRecord1}"/></td>
                    </tr>
                      <tr>
                        <td><c:customLookup objectAPIName="opportunity" IconName="standard:opportunity" label="Opportunity" selectedRecord="{!v.selectedLookUpRecord2}"/></td>
                    </tr>
                      
                        <div class="form-group">
                            <tr>
                            <td>
                        <p class="title">Priority</p>
                        <ui:inputSelect aura:id="InputSelectSingle" change="{!c.onSingleSelectChange}"  value="{!v.workorder.Priority}">
                            <ui:inputSelectOption text="Low"/>
                            <ui:inputSelectOption text="Medium"/>
                            <ui:inputSelectOption text="High"/>
                            <ui:inputSelectOption text="Critical"/>
                        </ui:inputSelect>
                     </td>
                     </tr>
                    </div>      
                     
                    </table>
                    </td>
                    <td width="10%"></td>
                    <td width="45%">
                        <table>
                        <tr>
                            <td>
                        <label>StartDate</label>
                        <ui:inputDate displayDatePicker="true" value="{!v.workorder.StartDate}"/>
                               </td>
                         </tr>
                    <div class="form-group">
                        <tr>
                            <td>
                        <p class="title">Status</p>
                        <ui:inputSelect aura:id="InputSelectSingle" change="{!c.onSingleSelectChange}"  value="{!v.workorder.Status}">
                            <ui:inputSelectOption text="New"/>
                            <ui:inputSelectOption text="In Progress"/>
                            <ui:inputSelectOption text="On Hold"/>
                            <ui:inputSelectOption text="Completed"/>
                            <ui:inputSelectOption text="Closed"/>
                            <ui:inputSelectOption text="Cannot Complete"/>
                            <ui:inputSelectOption text="Canceled"/>
                        </ui:inputSelect>
                        </td>
                      </tr>
                     </div>
                      <tr>
                        <td> 
                            <p class="title">Number of Visits</p>
                        <ui:inputNumber value="{!v.workorder.Number_of_Weeks__c}"/>
                        </td>
                     </tr>
                     <div class="form-group">
                        <tr>
                            <td>
                        <p class="title">Visit Frequency</p>
                        <ui:inputSelect aura:id="InputSelectSingle" change="{!c.onSingleSelectChange}"  value="{!v.workorder.Visit_Frequency__c}">
                            <ui:inputSelectOption text="None"/>
                            <ui:inputSelectOption text="Daily"/>
                            <ui:inputSelectOption text="Weekly"/>
                            <ui:inputSelectOption text="Monthly"/>
                            <ui:inputSelectOption text="Custom Schedule"/>
                        </ui:inputSelect>
                        </td>
                      </tr>
                     </div>
 
                </table>
                </td>
               
                  </tr>
                </thead>
            </table>
            <br/>
            <center>
                    <div class="col-md-4 text-center">
                        <lightning:button variant="brand" label="Save" onclick="{!c.create}"/>
                    </div>
                </center> 
            <br/>
        </div>
                    
      </div>
</aura:component>
Controller:
({
    create : function(component, event, helper) {
        console.log('Create record');
        
        //getting the workorder information
        var workorder = component.get("v.workorder");
        workorder.Account__c = null;
        workorder.Contact__c = null;
        workorder.Opportunity__c = null;
        
        /***************Validation
        if($A.util.isEmpty(workorder.Opportunity__c) || $A.util.isUndefined(workorder.Opportunity__c)){
            alert('Account Name is Required');
            return;           
        }*************************************************/
        if(component.get("v.selectedLookUpRecord").Id != undefined){
            workorder.Account__c = component.get("v.selectedLookUpRecord").Id;
        }
        if(component.get("v.selectedLookUpRecord1").Id != undefined){
            workorder.Contact__c = component.get("v.selectedLookUpRecord1").Id;
        }
        if(component.get("v.selectedLookUpRecord2").Id != undefined){
            workorder.Opportunity__c = component.get("v.selectedLookUpRecord2").Id;
        }
        
        //Calling the Apex Function
        var action = component.get("c.createRecord");
        
        //Setting the Apex Parameter
        action.setParams({
            workorder : workorder
        });
        
        //Setting the Callback
        action.setCallback(this,function(a){
            //get the response state
            var state = a.getState();
            
            //check if result is successfull
            if(state == "SUCCESS"){
                //Reset Form
                var newWorkorder = {'sobjectType': 'WorkOrder',
                                    'Account__c': '',
                                    'Contact__c': '',
                                    'Opportunity__c': '',
                                    'Priority': '',
                                    'StartDate': '',
                                    'Status': '',
                                    'Number_of_Weeks__c': '',
                                    'Visit_Frequency__c': '',
                                   };
                //resetting the Values in the form
                component.set("v.workorder",newWorkorder);
                alert('Record is Created Successfully');
            } else if(state == "ERROR"){
                alert('Error in calling server side action');
            }
        });
        
        //adds the server-side action to the queue        
        $A.enqueueAction(action);
        
    },
    
    onSingleSelectChange: function(cmp) {
         var selectCmp = cmp.find("InputSelectSingle");
         var resultCmp = cmp.find("singleResult");
         resultCmp.set("v.value", selectCmp.get("v.value"));
     },
     onChange: function(cmp) {
         var dynamicCmp = cmp.find("InputSelectDynamic");
         var resultCmp = cmp.find("dynamicResult");
         resultCmp.set("v.value", dynamicCmp.get("v.value"));
     }
})
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 All,
      Here is my apex trigger,
trigger LeadConversionTrigger on Lead (after update) {
    /*
     * Create maps of Ids to store the records
     * associated with the converted leads
     */
    Map<Id,Id> convertedOpportunityIds = new Map<Id,Id>();
    
    /*
     * Loop through the leads submitted through this
     * trigger.  Populate the appropriate maps of Ids
     * for each lead with populated values.
     */
    for (Lead l : Trigger.New) {
        
        // Get a reference to the old values associated
        // with this lead.
        Lead oldLead = trigger.OldMap.get(l.Id);
        
        // Determine if the lead was converted or not.
        // If the previous status was not converted and
        // the current status is converted, then this
        // trigger executed because of a conversion.
        if (!oldLead.IsConverted && l.isConverted) {
        
            // if lead was converted and converted opp id got populated
            if (l.convertedOpportunityId != null && oldLead.convertedOpportunityId == null ) {
                convertedOpportunityIds.put(l.Id, l.convertedOpportunityId);
            }
        }
    }
    
    List<Dealer_Registration_Product__c> dealerProducts = [SELECT Id, Name, Lead__c, Opportunity_Name__c FROM Dealer_Registration_Product__c 
                                                                WHERE Lead__c IN: convertedOpportunityIds.keySet() ];
    if ( dealerProducts != null && !dealerProducts.isEmpty() ) {
        for ( Dealer_Registration_Product__c product: dealerProducts ) {
            product.Opportunity_Name__c = convertedOpportunityIds.get( product.Lead__c);
        }
        update dealerProducts;
    }                                                        
}
and i have written the tes class as,
 
@IsTest
public class testLeadTriggers {
    public static testmethod void testContactIdAndConversion() 
    {
        Account acc = new Account( Name = ' name');
        insert acc;
        Contact cont = new Contact( FirstName = 'tt', LastName = 'Contact', AccountId = acc.Id);
        insert cont;
        Lead lead = new Lead( LastName = 'Lead', Company = ' company', Status = 'New', Contact_Id__c = cont.Id );
        insert lead;
        Lead testLead = [SELECT Id, Referred_By__c, Referred_End_User_Account__c FROM Lead WHERE Id =: lead.Id];
        System.AssertEquals( cont.Id, testLead.Referred_By__c );
        System.AssertEquals( acc.Id, testLead.Referred_End_User_Account__c );
        Opportunity opptyLine = new Opportunity (
            Name = 'discount 2',
            AccountID = acc.ID ,
            LeadSource= 'Inbound Call',
            Type ='Quota',
            CloseDate=Date.today(),
            StageName='5.Decision',
           Reseller__c = acc.ID,
            Distributor_Discount_Product_Temp__c=49.5,
            Distributor_Discount_Service_Temp__c=25,
                AIMS_Partner__c='Cerner'
             );
            insert opptyLine;
        
        Dealer_Registration_Product__c dealer = new Dealer_Registration_Product__c( Lead__c = lead.Id );
        insert dealer;
        
        Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(testLead.id);
        //lc.setDoNotCreateOpportunity(true);
        //lc.setOwnerId(testUser1.id);
        lc.setConvertedStatus('Converted');
        
       Database.LeadConvertResult lcr = Database.convertLead(lc);
      System.assert(lcr.isSuccess());
      opportunity opp = [select id from opportunity where AccountID=: acc.id];
        
        
        Dealer_Registration_Product__c testDealer = [SELECT Id, Opportunity_Name__c FROM Dealer_Registration_Product__c  WHERE Id =: dealer.Id ];
      //  System.Assert( testDealer.Opportunity_Name__c != null );
   
    }
}
But I am getting error as,

System.DmlException: ConvertLead failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, There was an error converting the lead. Please try again. If the problem persists, please contact your administrator.: []

Please advice to write the testclass.


Thanks and regards,
Sumitha.P


 
hi developers , i have an issue that i want to show all the fields labels in a textbox so that i can type few character then it will show all the related labels in there. thank you
Hello, I am having trouble with Process Builder being able to recognize null fileds. What I'm trying to do is have an email alert sent 14 days after the Invoice is received, if a PO number has not yet been assigned (no value in the PO Number field) - see pic below
User-added image
I have set the following conditions:
  • PO Number ISNULL Boolean True
  • Invoice Received equals yes
User-added image
However, when testing this process in Dev, it still sends email alerts even when I have assigned a PO Number to the issue. I only want it to do this is there is no PO Number. I have also tried a couple other conditions to recognize this, none of which I could get to work:
  • Is null > Boolean > false
  • Equals > GlobalConstant >$GlobalConstant.Null
  • Custom formula > PO Number__c = null
Additionally, when I do get an email alert, it sends two identical emails.

Any help would be greatly appreciated!
 
Hi All,

Can any one help to inlineedit an entire row in aura iteration and save the record in lightning?

Thanks,
ns

 
My requirement is just to run javascript code on click of custom button which is not supported in lightning. While calling the lightning component to run the JS code it shows a pop up. My requirement is not to show it. How it can be achieved?   
 Thanks in advance