• kapil sharma 185
  • NEWBIE
  • 5 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
Hello,
I get following error UpdateOverdueTasksCount: System.LimitException: Too many SOQL queries: 101 for this Trigger: 

// Every time a Task is created or updated,
// update the 'No of Overdue Tasks' in the Account object

trigger UpdateOverdueTasksCount on Task (after insert, after update) {
    for (Task myTask : Trigger.new) {
        String accid = myTask.AccountId;
        List<Task> task = [SELECT Id FROM Task WHERE isDeleted = FALSE AND activitydate < TODAY AND isclosed = FALSE AND AccountID = :accid];
        List<Account> account = [SELECT Id FROM Account WHERE Id = :accid];
        if (account.size() >0) {
            account[0].No_of_Overdue_Tasks__c = task.size();
            update account[0];
        }
    }
}

I don't know how to program. Could someone please help me what I need to change in this code to eliminate this error?

Thanks!
Monika
I am trying to integrate my wordpress site to the CRM SalesForce, to extract the data that I have in the CRM to a table of the wordpress database, but I can't find an api in the apis section that does this and I am not very clear how do it
public class MyDemo {
    public static void copyaccountphonetocontact(){
    list<contact>conlist=[SELECT Id,Firstname,Account.phone 
                           from contact 
                           where accountId !=null];
    if(!conlist.isEmpty()){
        for(contact con:conlist){
        if(con.phone==null){
            con.phone= con.account.phone;
        }
        
        }
    }
    if(!conlist.isEmpty()){
        update conlist;
    }
  }

}





how can resolved this error 



Line: 8, Column: 1
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Contact.Phone
I have a requirement to split the string based on delimeter, compare the tokens with specific value and if it finds a match, clear that specific value or replace it with other value .
Example 1 : string 'test,krishna,shekhar, karjun' need to be split based on comma (,) and compare each value with word 'shekhar', since match is found clear the word shekhar from original string . So the updated string value will be ''test,krishna,karjun' ( Shekhar is removed including delimeter )
Can you plesae suggest the best way to achieve this rquirement ?