• kuna
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 9
    Replies

I am trying to Auto populate the name of client in Related to Client field which is a custom field on standard Idea object .

Idea is a salesforce standard object.

Onclick of button I have to display relateded Opportunity Name on Related to opportunity test box.

I am trying to pass the value for Related to opportunity field as below in URL which i have written on button logic

https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c={! Opportunity.id}&Idea.Account__c={!Account.Id}&retURL=%2Fideas%2FideaList.apexp

On click of button I am getting Id in URL as below
https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c=006J00000024XX9&Idea.Account__c=001J0000002cQ1n&retURL=%2Fideas%2FideaList.apexp

Opportunity value is displaying on the text box.

Can anybody suggest on above issue.
how to populate value which i am passing in URL.
 

Idea object have Opportunity__c Look up fields with search option.From view source i got as below for Opportunity custom field
<input  id="thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c" maxlength="255" name="thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c" onchange="getElementByIdCS('thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_lkid').value='';getElementByIdCS('thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_mod').value='1';" size="20" type="text" /><script  type="text/javascript">
I have tried with below option but its not working.
Please help me on this.

https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c={!Opportunity.Name}&thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_lkid={!Opportunity.Id}&retURL=%2Fideas%2FideaList.apexp
https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&Opportunity__c={!Opportunity.Name}&Opportunity__c_lkid={!Opportunity.Id}&retURL=%2Fideas%2FideaList.apexp

Thanks
Ajit

  • February 05, 2012
  • Like
  • 0

I am trying to Auto populate the name of client in Related to Client field which is a custom field on standard Idea object .

Idea is a salesforce standard object.

Onclick of button I have to display relateded Opportunity Name on Related to opportunity test box.

I am trying to pass the value for Related to opportunity field as below in URL which i have written on button logic

https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c={! Opportunity.id}&Idea.Account__c={!Account.Id}&retURL=%2Fideas%2FideaList.apexp

On click of button I am getting Id in URL as below
https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c=006J00000024XX9&Idea.Account__c=001J0000002cQ1n&retURL=%2Fideas%2FideaList.apexp

Opportunity value is displaying on the text box.

Can anybody suggest on above issue.
how to populate value which i am passing in URL.
 

Idea object have Opportunity__c Look up fields with search option.From view source i got as below for Opportunity custom field
<input  id="thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c" maxlength="255" name="thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c" onchange="getElementByIdCS('thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_lkid').value='';getElementByIdCS('thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_mod').value='1';" size="20" type="text" /><script  type="text/javascript">
I have tried with below option but its not working.
Please help me on this.

https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c={!Opportunity.Name}&thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_lkid={!Opportunity.Id}&retURL=%2Fideas%2FideaList.apexp
https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&Opportunity__c={!Opportunity.Name}&Opportunity__c_lkid={!Opportunity.Id}&retURL=%2Fideas%2FideaList.apexp

Thanks
Ajit

  • February 05, 2012
  • Like
  • 0

I am trying to Auto populate the name of a client in Related to Client field in Idea Page .

Idea page is a salesforce standard page.

Onclick of button I have to pupulate the relateded client name in search test box.

I am passing the value for Related to client field as below in URL which is written on button logic

 

https://****.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c={! Opportunity.id}&Idea.Account__c={!Account.Id}&retURL=%2Fideas%2FideaList.apexp 

 

On click of button I am getting Id in URL as below

https://***.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c=006J00000024XX9&Idea.Account__c=001J0000002cQ1n&retURL=%2Fideas%2FideaList.apexp

 

Can anyone suggest Related to client field is not populating with the value which i am passing in URL. 

 

Thanks

Ajit

  • February 02, 2012
  • Like
  • 0

Hi,

 

I am new to salesforce and tring to update two fields on Account through trigger while changing on call report object.

Below code is working fine for single record as well as bulk record.

 

While mass data(80,000 record) update  trying to update i am getting System.LimitException: Too many script statements: 200001 for 900 records.

 

Almost all the record got updated successfully but getting error for few records.

 

Can anyone please suggest what needs to be changed so that i will not get the above error.

 

 

 

trigger DisplayRltdCallRepOnAcc on Call_Report__c(after insert, after update,after delete){
    List<Call_Report__c> lastcallRltdCallRepOnAcc = new List<Call_Report__c>();
    List<Call_Report__c> nextCallRltdCallRepOnAcc = new List<Call_Report__c>();
    Set<Id> updatelastCallAccountIds = new set<Id>();
    Set<Id> updateNextCallAccountIds = new set<Id>();
    List<Call_Report__c> rltdToClientIds = new List<Call_Report__c>();
    List<Account> updateAccLastCall = new List<Account>();
    List<Account> updateAccNextCall = new List<Account>();
       
    if(trigger.isInsert || trigger.isUpdate){
        System.debug('Trigger.New values:::::: '+trigger.new);
            rltdToClientIds = trigger.new;
    }else if(trigger.isDelete){
           // Note -- there is no trigger.new in delete 
           rltdToClientIds = trigger.old;
          }
    
    List < Id > clientIds = new List < Id >();
    if(rltdToClientIds.size() > 0){
        for ( Call_Report__c  c: rltdToClientIds){
            clientIds.add( c.Related_to_Client__c );
        }
    }
    System.debug('Related to Client IDS '+ clientIds.size());
    if(clientIds.size()> 0){
        lastcallRltdCallRepOnAcc = [Select Call_Date__c,Related_to_Client__c From Call_Report__c c where Status__c='Complete'
                                    and c.Type__c not in ('Attempt','Email') and Call_Date__c <= TODAY
                                    and Related_to_Client__c!=null and
                                    Related_to_Client__c IN :clientIds order by Call_Date__c desc];
    }
    System.debug('After Query for Last Call :::::size is '+ lastcallRltdCallRepOnAcc.size());

    Date lastCalldate;
    List<Date> callDateListLastCall = new list<Date>();
   
    if(clientIds.size() > 0){
    for(Id cId: clientIds){
        callDateListLastCall.clear();
        if(lastcallRltdCallRepOnAcc.size() > 0){
            For(Call_Report__c cReport:lastcallRltdCallRepOnAcc ){
                if(cId == cReport.Related_to_Client__c){
                    callDateListLastCall.add(cReport.Call_Date__c);                          
                }   
            }
            if(callDateListLastCall.size() > 0){   
                lastCalldate= callDateListLastCall[0];
            }
            for(Integer i=0; i< callDateListLastCall.size(); i++){
                if(lastCalldate <= callDateListLastCall[i] ){
                    lastCalldate = callDateListLastCall[i];
                }
            }
            if(cId != null) {
                Account acc = new Account(Id = cId ,Last_Call_Date__c = lastCalldate );       
                System.debug('--Last Call Date-- '+acc.Last_Call_Date__c);
                if(updatelastCallAccountIds.add(acc.Id)){
                    updateAccLastCall.add(acc);
                }
            }
        }else{
            if(cId != null){
            Account acc = new Account(Id =cId , Last_Call_Date__c = null);
             if(updatelastCallAccountIds.add(acc.Id)){
                 updateAccLastCall.add(acc);
             }       
            }
    }

    }
    System.debug('Last call update Account@@@ '+ updateAccLastCall.size());
    update updateAccLastCall;

    }   
     

   
    if(clientIds.size()> 0){
        nextCallRltdCallRepOnAcc = [Select Call_Date__c,Related_to_Client__c,Type__c From Call_Report__c c where Status__c='Incomplete'
                                    and c.Type__c not in ('Attempt','Email') and  Call_Date__c >= TODAY
                                    and Related_to_Client__c!=null and
                                    Related_to_Client__c IN :clientIds order by Call_Date__c asc];
    }
    System.debug('After Query for Next Call size is @@@ '+ nextCallRltdCallRepOnAcc.size());
 
    Date nextCalldate;
    List<Date> callDateListNextCall = new list<Date>();
    //Date compareDateNextCall;
    if(clientIds.size() > 0){
        for(Id cId: clientIds){
            callDateListNextCall.clear();
            if(nextCallRltdCallRepOnAcc.size() > 0){
                For(Call_Report__c cReport:nextCallRltdCallRepOnAcc){
                    if(cId == cReport.Related_to_Client__c){
                        callDateListNextCall.add(cReport.Call_Date__c);                          
                    }   
                }
                if(callDateListNextCall.size() >0){
                    nextCalldate= callDateListNextCall[0];
                }
                for(Integer i=0; i< callDateListNextCall.size(); i++){
                    if(nextCalldate >= callDateListNextCall[i] ){
                        nextCalldate = callDateListNextCall[i];
                    }
                }
                if(cId != null) {
                    Account acc1 = new Account(Id = cId ,Next_Scheduled_Call__c = nextCalldate);       
                    System.debug('--Next Call Date-- '+acc1.Next_Scheduled_Call__c);
                    if(updateNextCallAccountIds.add(acc1.Id)){
                        updateAccNextCall.add(acc1);
                    }
                }   
            }else{
                if(cId != null){
                Account acc1 = new Account(Id = cId, Next_Scheduled_Call__c = null);
                    if(updateNextCallAccountIds.add(acc1.Id)){
                        updateAccNextCall.add(acc1);
                    }
               }       
            } 
        }
        System.debug('Next call update Account@@@ '+ updateAccNextCall.size());
        update updateAccNextCall;
    } 
  
}

  • November 01, 2011
  • Like
  • 0

Hello,

I am using a soql query to retrieve records from Call Report.

I am able to execute this if i have less records but if i have more records that is fr about 200 Records i am getting an exception:
Too many SOQL queries: 101 .
Please help me out of this issue.


Here is my code :

 

 

trigger DisplayRltdCallRepOnAcc on Call_Report__c(after insert, after update,after delete){
    List<Call_Report__c> lastcallRltdCallRepOnAcc = new List<Call_Report__c>();
    String relatedToClientLastCall;
    List<Account> updateAccLastCall = new List<Account>();
    Set<Id> updatelastCallAccountIds = new set<Id>();
   
    List<Call_Report__c> nextCallRltdCallRepOnAcc = new List<Call_Report__c>();
    List<Account> accsToUpdateNextCall = new List<Account>();
    String relatedToClientNextCall;
    List<Account> updateAccNextCall = new List<Account>();
    Set<Id> updateNextCallAccountIds = new set<Id>();

   
    List<Call_Report__c> rltdToClientIds = new List<Call_Report__c>();
       
    if(trigger.isInsert || trigger.isUpdate){
    System.debug('Trigger.New values:::::: '+trigger.new);
        rltdToClientIds = trigger.new;
    }else if(trigger.isDelete){
     // Note -- there is no trigger.new in delete 
       rltdToClientIds = trigger.old;
     }
     System.debug('Related to Client IDS '+ rltdToClientIds.size());
     for(Call_Report__c calldates : rltdToClientIds){
    
        if(calldates.Related_to_Client__c != null){
            lastcallRltdCallRepOnAcc = [Select Call_Date__c,Related_to_Client__c From Call_Report__c c where Status__c='Complete'
                               and c.Type__c not in ('Attempt','Email') and Call_Date__c <= TODAY
                               and Related_to_Client__c!=null and
                               Related_to_Client__c =:calldates.Related_to_Client__c order by Call_Date__c desc];
        relatedToClientLastCall = calldates.Related_to_Client__c;
        }
        if(lastcallRltdCallRepOnAcc.size() > 0){
             System.debug('Last Call Date '+lastcallRltdCallRepOnAcc[0].Call_Date__c);
             Account acc = new Account(Id = lastcallRltdCallRepOnAcc[0].Related_to_Client__c,Last_Call_Date__c = lastcallRltdCallRepOnAcc[0].Call_Date__c);
             if(updatelastCallAccountIds.add(acc.Id)){
                 updateAccLastCall.add(acc);
             }
         }
         else{
             if(relatedToClientLastCall != null){
                 Account acc = new Account(Id = relatedToClientLastCall, Last_Call_Date__c = null);
                 if(updatelastCallAccountIds.add(acc.Id)){
                     updateAccLastCall.add(acc);
                 }
             }
         }
       }

}

 

 

 

 

 

 

Thanks in advance,
Ajit.

  • October 14, 2011
  • Like
  • 0

I am trying to Auto populate the name of client in Related to Client field which is a custom field on standard Idea object .

Idea is a salesforce standard object.

Onclick of button I have to display relateded Opportunity Name on Related to opportunity test box.

I am trying to pass the value for Related to opportunity field as below in URL which i have written on button logic

https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c={! Opportunity.id}&Idea.Account__c={!Account.Id}&retURL=%2Fideas%2FideaList.apexp

On click of button I am getting Id in URL as below
https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c=006J00000024XX9&Idea.Account__c=001J0000002cQ1n&retURL=%2Fideas%2FideaList.apexp

Opportunity value is displaying on the text box.

Can anybody suggest on above issue.
how to populate value which i am passing in URL.
 

Idea object have Opportunity__c Look up fields with search option.From view source i got as below for Opportunity custom field
<input  id="thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c" maxlength="255" name="thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c" onchange="getElementByIdCS('thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_lkid').value='';getElementByIdCS('thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_mod').value='1';" size="20" type="text" /><script  type="text/javascript">
I have tried with below option but its not working.
Please help me on this.

https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c={!Opportunity.Name}&thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_lkid={!Opportunity.Id}&retURL=%2Fideas%2FideaList.apexp
https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&Opportunity__c={!Opportunity.Name}&Opportunity__c_lkid={!Opportunity.Id}&retURL=%2Fideas%2FideaList.apexp

Thanks
Ajit

  • February 05, 2012
  • Like
  • 0

I am trying to Auto populate the name of client in Related to Client field which is a custom field on standard Idea object .

Idea is a salesforce standard object.

Onclick of button I have to display relateded Opportunity Name on Related to opportunity test box.

I am trying to pass the value for Related to opportunity field as below in URL which i have written on button logic

https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c={! Opportunity.id}&Idea.Account__c={!Account.Id}&retURL=%2Fideas%2FideaList.apexp

On click of button I am getting Id in URL as below
https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c=006J00000024XX9&Idea.Account__c=001J0000002cQ1n&retURL=%2Fideas%2FideaList.apexp

Opportunity value is displaying on the text box.

Can anybody suggest on above issue.
how to populate value which i am passing in URL.
 

Idea object have Opportunity__c Look up fields with search option.From view source i got as below for Opportunity custom field
<input  id="thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c" maxlength="255" name="thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c" onchange="getElementByIdCS('thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_lkid').value='';getElementByIdCS('thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_mod').value='1';" size="20" type="text" /><script  type="text/javascript">
I have tried with below option but its not working.
Please help me on this.

https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c={!Opportunity.Name}&thePage:mainLayout:formIdea:pb:ideaCustomFields:Opportunity__c_lkid={!Opportunity.Id}&retURL=%2Fideas%2FideaList.apexp
https://cs10.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&Opportunity__c={!Opportunity.Name}&Opportunity__c_lkid={!Opportunity.Id}&retURL=%2Fideas%2FideaList.apexp

Thanks
Ajit

  • February 05, 2012
  • Like
  • 0

I am trying to Auto populate the name of a client in Related to Client field in Idea Page .

Idea page is a salesforce standard page.

Onclick of button I have to pupulate the relateded client name in search test box.

I am passing the value for Related to client field as below in URL which is written on button logic

 

https://****.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c={! Opportunity.id}&Idea.Account__c={!Account.Id}&retURL=%2Fideas%2FideaList.apexp 

 

On click of button I am getting Id in URL as below

https://***.salesforce.com/ideas/editIdea.apexp?c=09aJ00000004CgR&idea.Opportunity__c=006J00000024XX9&Idea.Account__c=001J0000002cQ1n&retURL=%2Fideas%2FideaList.apexp

 

Can anyone suggest Related to client field is not populating with the value which i am passing in URL. 

 

Thanks

Ajit

  • February 02, 2012
  • Like
  • 0

Hi,

 

I am new to salesforce and tring to update two fields on Account through trigger while changing on call report object.

Below code is working fine for single record as well as bulk record.

 

While mass data(80,000 record) update  trying to update i am getting System.LimitException: Too many script statements: 200001 for 900 records.

 

Almost all the record got updated successfully but getting error for few records.

 

Can anyone please suggest what needs to be changed so that i will not get the above error.

 

 

 

trigger DisplayRltdCallRepOnAcc on Call_Report__c(after insert, after update,after delete){
    List<Call_Report__c> lastcallRltdCallRepOnAcc = new List<Call_Report__c>();
    List<Call_Report__c> nextCallRltdCallRepOnAcc = new List<Call_Report__c>();
    Set<Id> updatelastCallAccountIds = new set<Id>();
    Set<Id> updateNextCallAccountIds = new set<Id>();
    List<Call_Report__c> rltdToClientIds = new List<Call_Report__c>();
    List<Account> updateAccLastCall = new List<Account>();
    List<Account> updateAccNextCall = new List<Account>();
       
    if(trigger.isInsert || trigger.isUpdate){
        System.debug('Trigger.New values:::::: '+trigger.new);
            rltdToClientIds = trigger.new;
    }else if(trigger.isDelete){
           // Note -- there is no trigger.new in delete 
           rltdToClientIds = trigger.old;
          }
    
    List < Id > clientIds = new List < Id >();
    if(rltdToClientIds.size() > 0){
        for ( Call_Report__c  c: rltdToClientIds){
            clientIds.add( c.Related_to_Client__c );
        }
    }
    System.debug('Related to Client IDS '+ clientIds.size());
    if(clientIds.size()> 0){
        lastcallRltdCallRepOnAcc = [Select Call_Date__c,Related_to_Client__c From Call_Report__c c where Status__c='Complete'
                                    and c.Type__c not in ('Attempt','Email') and Call_Date__c <= TODAY
                                    and Related_to_Client__c!=null and
                                    Related_to_Client__c IN :clientIds order by Call_Date__c desc];
    }
    System.debug('After Query for Last Call :::::size is '+ lastcallRltdCallRepOnAcc.size());

    Date lastCalldate;
    List<Date> callDateListLastCall = new list<Date>();
   
    if(clientIds.size() > 0){
    for(Id cId: clientIds){
        callDateListLastCall.clear();
        if(lastcallRltdCallRepOnAcc.size() > 0){
            For(Call_Report__c cReport:lastcallRltdCallRepOnAcc ){
                if(cId == cReport.Related_to_Client__c){
                    callDateListLastCall.add(cReport.Call_Date__c);                          
                }   
            }
            if(callDateListLastCall.size() > 0){   
                lastCalldate= callDateListLastCall[0];
            }
            for(Integer i=0; i< callDateListLastCall.size(); i++){
                if(lastCalldate <= callDateListLastCall[i] ){
                    lastCalldate = callDateListLastCall[i];
                }
            }
            if(cId != null) {
                Account acc = new Account(Id = cId ,Last_Call_Date__c = lastCalldate );       
                System.debug('--Last Call Date-- '+acc.Last_Call_Date__c);
                if(updatelastCallAccountIds.add(acc.Id)){
                    updateAccLastCall.add(acc);
                }
            }
        }else{
            if(cId != null){
            Account acc = new Account(Id =cId , Last_Call_Date__c = null);
             if(updatelastCallAccountIds.add(acc.Id)){
                 updateAccLastCall.add(acc);
             }       
            }
    }

    }
    System.debug('Last call update Account@@@ '+ updateAccLastCall.size());
    update updateAccLastCall;

    }   
     

   
    if(clientIds.size()> 0){
        nextCallRltdCallRepOnAcc = [Select Call_Date__c,Related_to_Client__c,Type__c From Call_Report__c c where Status__c='Incomplete'
                                    and c.Type__c not in ('Attempt','Email') and  Call_Date__c >= TODAY
                                    and Related_to_Client__c!=null and
                                    Related_to_Client__c IN :clientIds order by Call_Date__c asc];
    }
    System.debug('After Query for Next Call size is @@@ '+ nextCallRltdCallRepOnAcc.size());
 
    Date nextCalldate;
    List<Date> callDateListNextCall = new list<Date>();
    //Date compareDateNextCall;
    if(clientIds.size() > 0){
        for(Id cId: clientIds){
            callDateListNextCall.clear();
            if(nextCallRltdCallRepOnAcc.size() > 0){
                For(Call_Report__c cReport:nextCallRltdCallRepOnAcc){
                    if(cId == cReport.Related_to_Client__c){
                        callDateListNextCall.add(cReport.Call_Date__c);                          
                    }   
                }
                if(callDateListNextCall.size() >0){
                    nextCalldate= callDateListNextCall[0];
                }
                for(Integer i=0; i< callDateListNextCall.size(); i++){
                    if(nextCalldate >= callDateListNextCall[i] ){
                        nextCalldate = callDateListNextCall[i];
                    }
                }
                if(cId != null) {
                    Account acc1 = new Account(Id = cId ,Next_Scheduled_Call__c = nextCalldate);       
                    System.debug('--Next Call Date-- '+acc1.Next_Scheduled_Call__c);
                    if(updateNextCallAccountIds.add(acc1.Id)){
                        updateAccNextCall.add(acc1);
                    }
                }   
            }else{
                if(cId != null){
                Account acc1 = new Account(Id = cId, Next_Scheduled_Call__c = null);
                    if(updateNextCallAccountIds.add(acc1.Id)){
                        updateAccNextCall.add(acc1);
                    }
               }       
            } 
        }
        System.debug('Next call update Account@@@ '+ updateAccNextCall.size());
        update updateAccNextCall;
    } 
  
}

  • November 01, 2011
  • Like
  • 0

Hello,

I am using a soql query to retrieve records from Call Report.

I am able to execute this if i have less records but if i have more records that is fr about 200 Records i am getting an exception:
Too many SOQL queries: 101 .
Please help me out of this issue.


Here is my code :

 

 

trigger DisplayRltdCallRepOnAcc on Call_Report__c(after insert, after update,after delete){
    List<Call_Report__c> lastcallRltdCallRepOnAcc = new List<Call_Report__c>();
    String relatedToClientLastCall;
    List<Account> updateAccLastCall = new List<Account>();
    Set<Id> updatelastCallAccountIds = new set<Id>();
   
    List<Call_Report__c> nextCallRltdCallRepOnAcc = new List<Call_Report__c>();
    List<Account> accsToUpdateNextCall = new List<Account>();
    String relatedToClientNextCall;
    List<Account> updateAccNextCall = new List<Account>();
    Set<Id> updateNextCallAccountIds = new set<Id>();

   
    List<Call_Report__c> rltdToClientIds = new List<Call_Report__c>();
       
    if(trigger.isInsert || trigger.isUpdate){
    System.debug('Trigger.New values:::::: '+trigger.new);
        rltdToClientIds = trigger.new;
    }else if(trigger.isDelete){
     // Note -- there is no trigger.new in delete 
       rltdToClientIds = trigger.old;
     }
     System.debug('Related to Client IDS '+ rltdToClientIds.size());
     for(Call_Report__c calldates : rltdToClientIds){
    
        if(calldates.Related_to_Client__c != null){
            lastcallRltdCallRepOnAcc = [Select Call_Date__c,Related_to_Client__c From Call_Report__c c where Status__c='Complete'
                               and c.Type__c not in ('Attempt','Email') and Call_Date__c <= TODAY
                               and Related_to_Client__c!=null and
                               Related_to_Client__c =:calldates.Related_to_Client__c order by Call_Date__c desc];
        relatedToClientLastCall = calldates.Related_to_Client__c;
        }
        if(lastcallRltdCallRepOnAcc.size() > 0){
             System.debug('Last Call Date '+lastcallRltdCallRepOnAcc[0].Call_Date__c);
             Account acc = new Account(Id = lastcallRltdCallRepOnAcc[0].Related_to_Client__c,Last_Call_Date__c = lastcallRltdCallRepOnAcc[0].Call_Date__c);
             if(updatelastCallAccountIds.add(acc.Id)){
                 updateAccLastCall.add(acc);
             }
         }
         else{
             if(relatedToClientLastCall != null){
                 Account acc = new Account(Id = relatedToClientLastCall, Last_Call_Date__c = null);
                 if(updatelastCallAccountIds.add(acc.Id)){
                     updateAccLastCall.add(acc);
                 }
             }
         }
       }

}

 

 

 

 

 

 

Thanks in advance,
Ajit.

  • October 14, 2011
  • Like
  • 0