• Sheed
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
I need to convert a string that I am getting from JSON response (For eg: 2018-05-29T22:57:11.000-07:00) to DateTime  (eg:2014-03-29 06:09:36) 

what should i do?
  • November 06, 2018
  • Like
  • 0
list<HCP_User_BMS_CN__c> hcplist =[SELECT ,Hospital_Name_BMS_CN__c, Id, User_BMS_CN__r.name, Status_BMS_CN__c FROM HCP_User_BMS_CN__c  ];
for(HCP_User_BMS_CN__c hcp : hcplist){
    String hco = hcp.Hospital_Name_BMS_CN__c;
    String temp='';
    for (integer i = 0; i < hco.length(); i++) {
        temp += hco.substring(i, i+1) + '%';
    }
    String hcolike ='%'+temp ;
    
    list<Account> hcos = [SELECT Name FROM Account where  Name like: hcolike];
    list<String> hcolist = new list<String>();
    for (integer i = 0; i < hcos.size(); i++) {
        hcolist.add(hcos[i].Name);
    }
    //System.debug('hcolist'+'   '+hco+' '+hcolist.size());
    
    if(hcolist.size()>0){
        list<Account> acclist = [select id ,Name,Primary_Parent_vod__r.Name FROM Account where Primary_Parent_vod__r.Name in :hcolist and Name=:hcp.User_BMS_CN__r.name];
        if(acclist.size()>0){
           System.debug('acclist'+acclist); 
        }
    }
}

Because soql inside a for loop ,I am Getting This Below Error:System.LimitException: Too many SOQL queries: 101 . How to deal with it?
  • September 05, 2018
  • Like
  • 0