• Nick00000
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 14
    Replies

Hi,

 

I'm finding difficulty in  solving  this issue.When i tried to run atrigger its is showing Too many SOQL queries exception.I know this is because of soql inside for loop..I donot see any queries inside for loop .I cannot find why this error showing if not

 

trigger CarparkUpdate on Opportunity (after insert, after update) {

    List<Id> cId = new List<Id>();
    List<Id> old_cid = new List<Id> ();
    List<Car_Park__c> lstCp,lstCp1;
    Map<Id,Car_Park__c> mapCp = new Map<Id,Car_Park__c> ();
    Map<Id,Car_Park__c> mapCp1 = new Map<Id,Car_Park__c> ();
    
     System.debug('Total Number of SOQL Queries allowed in this apex code context: ' +  Limits.getLimitQueries());

    System.debug('Total Number of records that can be queried  in this apex code context: ' +  Limits.getLimitDmlRows());

    System.debug('Total Number of DML statements allowed in this apex code context: ' +  Limits.getLimitDmlStatements() );

    System.debug('Total Number of script statements allowed in this apex code context: ' +  Limits.getLimitScriptStatements());

     

   if(Trigger.oldMap != null) 
  {
        
        
        for(Opportunity O: Trigger.old){
            old_cid.add(O.Car_Park__c);
            system.debug('OLdcid'+old_cid);
            }
            system.debug('CID111111111111111'+old_cid);
          
            List<Car_Park__c>  Cp1 =[select id from Car_Park__c where id=: old_cid];
            system.debug('1stCp111111111111111'+Cp1.size());
            lstCp1 = [select id,Status__c from Car_Park__c where id IN: old_cid];//Too many SOQL queries Exception
            System.debug('1.Number of Queries used in this apex code so far: ' + Limits.getQueries());
            System.debug('2.Number of rows queried in this apex code so far: ' + Limits.getDmlRows());
            System.debug('3.Number of script statements used so far : ' +  Limits.getDmlStatements());
            System.debug('4.Number of Queries used in this apex code so far: ' + Limits.getQueries());
            System.debug('5.Number of rows queried in this apex code so far: ' + Limits.getDmlRows());
          
              for(Car_Park__c a : lstCp1) {
                mapCP1.put(a.Id,a);
              }
         //System.debug('#### mapCP1: ' + mapCP1.size());
      
        
        
   }  
    
         for(Opportunity O : Trigger.new) {
         cId.add(O.Car_Park__c);
        }

     lstCp = [select Status__c from Car_Park__c where id IN: cId];
     for(Car_Park__c a : lstCp) {
        mapCP.put(a.Id,a);
     }
     for(Opportunity O:trigger.new) {
        if(O.Car_Park__c != null) {            
            //if(O.Stagename == 'Blocking' || O.Stagename == 'Documentation Handoff')
            mapCp.get(O.Car_Park__c).Status__c='Blocked';
        }
    }
    if(Trigger.oldMap != null && mapCp1.size() !=0) {
        for(Opportunity O: Trigger.old){
            if(Trigger.newMap.get(o.Id).Car_Park__c == null)
                mapCp1.get(O.Car_Park__c).Status__c='Available';
            else
                mapCp1.get(O.Car_Park__c).Status__c = mapCp.get(O.Car_Park__c).Status__c;
        }
    }

}

 

 

Thanks

 
 

 Can anyone please help me to solve this issue asap.

 

Thanks

  • March 13, 2012
  • Like
  • 0

I have different levels

1.Apex:page

2.form

3.pageblock

3.pageblocksection

4.inputfield

 

Every level has their ids.Now in JScript I want to traverse through ids by document.getElementById....how to traverse ?Directly using .inputfield id is not working,,,,,Suggestion please!

When i trying to create WSDL in salesforce from Webservices that is provided from External systems..... Following error msg  gets displayed in salesforce.........

 

 

Error MEssage:

 

 Failed to parse wsdl: Unable to find schema for element; {http://www.w3.org/2001/XMLSchema}schema

 

Please let me know if you need WSDL?

 

Thanks in Advance....!!!!!

Using the API (i.e. SOQL), what is the fastest way to find all the child accounts from a specified account id?  Is my only option to query all accounts and their parents using something like:

 

SELECT Parent.ParentId, Parent.Parent.ParentId, Parent.Parent.Parent.ParentId, Parent.Parent.Parent.Parent.ParentId, Parent.Parent.Parent.Parent.Parent.ParentId FROM Account

 and then resursively iterate through the result set looking for accounts related to my specified account id?

i am having trouble getting connection Hoovers Api, i have given accesss to http://hapi.hoovers.com

In this i am getting exception-------------------  System.HttpResponse[Status=Forbidden, StatusCode=403]

 

Please do respond urgently

 

Heres my code i got it fromlink::::

http://boards.developerforce.com/t5/forums/forumtopicprintpage/board-id/apex/message-id/77643/print-single-message/true/page/1

 

global with sharing class HttpCallout_CLS{

String Accid = apexPages.currentPage().getParameters().get('id');

Public void sendRequest(){
    String env;
    integer j,k;
    HttpRequest req = new HttpRequest();
    req.setMethod('GET');
    req.setHeader('content-type','text/xml');

    req.setEndpoint('http://hapi.hoovers.com/HooversAPI-32');
    String API_KEY = 'XXXX'; // Use Api Key
    Blob headerValue = Blob.valueOf(API_KEY);
    String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
    req.setHeader('Authorization', authorizationHeader);
    String CName = apexPages.currentPage().getParameters().get('Name');

  

              // **** removing special characters from a account name*****
    
    List<String> spl= New List<String>{'@','#','$','%','^','&','*','(',')','!','.','"','<','>','?'};
    List<String> li = New List<String>();
    String CompName='';
    for(j=0;j<CName.length();j++){
      li.add(CName.substring(j,j+1));
     }
    for(j=0;j<CName.length();j++){
        for(k=0;k<spl.size();k++){
            if(li[j]==spl[k]){
                 li[j]=' ';
                 break;           
            }
        }
    }  
   for(Integer l=0;l<li.size();l++){
       CompName = CompName + li[l];
    }

//constucting request body

 env = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://applications.dnb.com/webservice/schema/">'+
            '<soapenv:Header>'+
              '<sch:API-KEY>xxxx</sch:API-KEY>'+
            '</soapenv:Header>'+
            '<soapenv:Body>'+
              '<sch:FindCompanyByKeywordRequest>'+
              '<sch:maxRecords>100</sch:maxRecords>'+
              '<sch:sortDirection>Ascending</sch:sortDirection>'+
              '<sch:keyword>'+CompName+'</sch:keyword>'+  // search keyword
              '<sch:searchBy>companyName</sch:searchBy>'+
              '<sch:returnSearchNavigation>true</sch:returnSearchNavigation>'+
              '<sch:orderBy>CompanyName</sch:orderBy>'+
              '<sch:searchNavigation>'+
                '<sch:employeeSearchNavigation>'+
                '</sch:employeeSearchNavigation>'+
                '<sch:ownershipTypeSearchNavigation>'+
                '</sch:ownershipTypeSearchNavigation>'+
                '<sch:locationTypeSearchNavigation>'+
                '</sch:locationTypeSearchNavigation>'+
                  '<sch:salesSearchNavigation>'+
                  '</sch:salesSearchNavigation>'+
                  '<sch:industrySearchNavigation>'+
                 '</sch:industrySearchNavigation>'+
                '</sch:searchNavigation>'+
               '</sch:FindCompanyByKeywordRequest>'+
              '</soapenv:Body>'+
             '</soapenv:Envelope>';      

 

     req.setBody(env);  // sending request to the API
    System.debug(req.getBody());     
   Http http = new Http();

   HTTPResponse res = http.send(req);  // getting response from the API

 System.debug(res);

 

 

 

 

Regards

Punnoose

I have an Apex class that can be invoked from a REST Get :

 

@HttpGet

global static Set<Id> doGet() {

.......

}

 

However the compiler is complaining with:

Invalid type for Http* method: SET<Id>

 

Am I only allowed to return a concrete object type?

  • April 04, 2012
  • Like
  • 0

Hi,

 

I'm finding difficulty in  solving  this issue.When i tried to run atrigger its is showing Too many SOQL queries exception.I know this is because of soql inside for loop..I donot see any queries inside for loop .I cannot find why this error showing if not

 

trigger CarparkUpdate on Opportunity (after insert, after update) {

    List<Id> cId = new List<Id>();
    List<Id> old_cid = new List<Id> ();
    List<Car_Park__c> lstCp,lstCp1;
    Map<Id,Car_Park__c> mapCp = new Map<Id,Car_Park__c> ();
    Map<Id,Car_Park__c> mapCp1 = new Map<Id,Car_Park__c> ();
    
     System.debug('Total Number of SOQL Queries allowed in this apex code context: ' +  Limits.getLimitQueries());

    System.debug('Total Number of records that can be queried  in this apex code context: ' +  Limits.getLimitDmlRows());

    System.debug('Total Number of DML statements allowed in this apex code context: ' +  Limits.getLimitDmlStatements() );

    System.debug('Total Number of script statements allowed in this apex code context: ' +  Limits.getLimitScriptStatements());

     

   if(Trigger.oldMap != null) 
  {
        
        
        for(Opportunity O: Trigger.old){
            old_cid.add(O.Car_Park__c);
            system.debug('OLdcid'+old_cid);
            }
            system.debug('CID111111111111111'+old_cid);
          
            List<Car_Park__c>  Cp1 =[select id from Car_Park__c where id=: old_cid];
            system.debug('1stCp111111111111111'+Cp1.size());
            lstCp1 = [select id,Status__c from Car_Park__c where id IN: old_cid];//Too many SOQL queries Exception
            System.debug('1.Number of Queries used in this apex code so far: ' + Limits.getQueries());
            System.debug('2.Number of rows queried in this apex code so far: ' + Limits.getDmlRows());
            System.debug('3.Number of script statements used so far : ' +  Limits.getDmlStatements());
            System.debug('4.Number of Queries used in this apex code so far: ' + Limits.getQueries());
            System.debug('5.Number of rows queried in this apex code so far: ' + Limits.getDmlRows());
          
              for(Car_Park__c a : lstCp1) {
                mapCP1.put(a.Id,a);
              }
         //System.debug('#### mapCP1: ' + mapCP1.size());
      
        
        
   }  
    
         for(Opportunity O : Trigger.new) {
         cId.add(O.Car_Park__c);
        }

     lstCp = [select Status__c from Car_Park__c where id IN: cId];
     for(Car_Park__c a : lstCp) {
        mapCP.put(a.Id,a);
     }
     for(Opportunity O:trigger.new) {
        if(O.Car_Park__c != null) {            
            //if(O.Stagename == 'Blocking' || O.Stagename == 'Documentation Handoff')
            mapCp.get(O.Car_Park__c).Status__c='Blocked';
        }
    }
    if(Trigger.oldMap != null && mapCp1.size() !=0) {
        for(Opportunity O: Trigger.old){
            if(Trigger.newMap.get(o.Id).Car_Park__c == null)
                mapCp1.get(O.Car_Park__c).Status__c='Available';
            else
                mapCp1.get(O.Car_Park__c).Status__c = mapCp.get(O.Car_Park__c).Status__c;
        }
    }

}

 

 

Thanks

 
 

 Can anyone please help me to solve this issue asap.

 

Thanks

  • March 13, 2012
  • Like
  • 0

I'm trying to verify that my code is permanently deleting objects.  For some reason, the test still finds the newly inserted tasks when I query ALL ROWS -even though I just purged it from the recycle bin.  Any ideas how I can test that a record was purged from the recycle bin successfully?

 

Any help is appreciated,

 

Andrew

 

Here's my test code:

 

	static testMethod void testPermanentDelete()
	{
		Task t = new Task(
			Subject = 'subject',
			Priority = 'Normal',
			Status = 'Completed',
			ActivityDate = Date.today());
		insert t;
		Id taskId = t.Id;
		
		//Verify the task was inserted
		List<Task> foundTasks = [Select Id From Task Where Id = :taskId ALL ROWS];
		System.assertEquals(1, foundTasks.size());
		
		Test.startTest();		
		Database.DeleteResult[] deleteResults = Database.delete(foundTasks, false);
		Database.EmptyRecycleBinResult[] emptyRecycleBinResults = Database.emptyRecycleBin(foundTasks);
		Test.stopTest();
		
		//Verify the task was permanently deleted
		foundTasks = [Select Id From Task Where Id = :taskId ALL ROWS];
		System.assertEquals(0, foundTasks.size());
	}

 

HI All, I tried a lot.But didn't get the solution.

 

           I have a custom objects Registration_level__c and Attendee_Session__c. The  Attendee_Session__c custom object has lookup field of Registration_level__c.

 

           How can I display the related list of Attendee_Session__c which is in Registration_level__c detail page in a visualforce page.

 

 

Kindly help me. If you need any more information please let me know.

 

Thanks,

Naresh

Hi,

 

I have designed two custom objects(say Table1 and Table2) having parent-child relationship. Table2 has one master-detail field(say field1).

I am trying to fetch the from two tables by following query

 

list<sobject> objlist= Database.query('SELECT Id, Name, field1__r.Name  FROM Table2');
    for(sObject sobj: objList) {
     
       String ID = sObj.get('id')+'';
       String Name = sObj.get('name')+'';
       // Here i am requiring the code to fectch parent table(i.e Table1) data


}   

 

 

I dont know the syntax to fetch the parent table data, kindly let me know about the required code

 

          

  • October 19, 2011
  • Like
  • 0

Hi,

 

Am facing a problem in creating a workflow process, we are using professional edition and have workflow process activated, I had to build 2 step approval process, was successful in creating the first step, but am not able to see the option for creating the second step in approval detail page. All the steps in the available SFDC documentation shows the option to create the steps, but am not able to figure out the same as I don't find the option for creating multiple steps. pl help me out of am doing something wrong here.

 

Thanks in advance

Gowtham

  • October 19, 2011
  • Like
  • 0

I am serching for date in my code. But am am not able to get it please help me it is urgent. I am new to salesforce. 

<apex:page controller="apposearchController" sidebar="false">
  <apex:form > 
     <apex:pageMessages id="errors" />
      <apex:pageBlock title="Appoinment!" mode="edit">
        <table>
            <tr>
                <td width="200" valign="top">
                <apex:pageBlock title="Parameters" mode="edit" id="criteria">
                    <script type="text/javascript">
                              function doSearch() {
                                searchServer(
                                document.getElementById("AppoinmentType").value,
                                document.getElementById("Clint").value,
                                document.getElementById("StartDate").value,
                                document.getElementById("Status").options[document.getElementById("Status").selectedIndex].value
                                );
                              }
                        </script>
                        
                        <script type="text/javascript" src="clear-default-text.js"></script>
                        
                        <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
                         <apex:param name="AppoinmentType" value="" />
                         <apex:param name="Clint" value="" />
                         <apex:param name="StartDate" value="" />
                         <apex:param name="Status" value="" />
                        </apex:actionFunction>
                         
                         <table cellpadding="2" cellspacing="2">
                             <tr>
                            <td style="font-weight:bold;">Appoinment Type<br/>
                            <input type="text" id="AppoinmentType" onkeyup="doSearch();" class="cleardefault"/>
                            </td>
                          </tr>
                          <tr>
                            <td style="font-weight:bold;">Clint<br/>
                            <input type="text" id="Clint" onkeyup="doSearch();" class="cleardefault"/>
                            </td>
                          </tr>
                          <tr>
                            <td style="font-weight:bold;">Start Date<br/>
                            <input type="text" id="StartDate" onkeyup="doSearch();" class="cleardefault"/>
                            </td>
                          </tr>
                          <tr>
                            <td style="font-weight:bold;">Status<br/>
                              <select id="Status" onchange="doSearch();">
                                <option value=""></option>
                                <apex:repeat value="{!Status}" var="tech">
                                  <option value="{!tech}">{!tech}</option>
                                </apex:repeat>
                              </select>
                            </td>
                          </tr>
                        </table>
                </apex:pageBlock>
                </td>
                <td valign="top">
                    <apex:pageBlock mode="edit" id="results">
                         <apex:pageBlockTable value="{!Appoinment}" var="Appointment">
                             <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="AppoinmentType" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Appointment_Type__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Appointment.Appointment_Type__c}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Clint" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Client__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Appointment.Client__c}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="StartDate" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Start_Date__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Appointment.Start_Date__c}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Status" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Status__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Appointment.Status__c}"/>
            </apex:column>
                         </apex:pageBlockTable>
                    </apex:pageBlock>
                </td>
            </tr>
        </table>      
    
           <apex:pageBlock title="Debug - SOQL" id="debug">
              <apex:outputText value="{!debugSoql}" />           
          </apex:pageBlock>
          

          
          </apex:pageBlock>
    
  </apex:form>
</apex:page>

 

public class apposearchController
{
    public List<Appointment1__c> Appoinment{get;set;}
    private String soql {get;set;}
    public String technologies { get; set; }
    
    public String sortDir 
    {
        get  { if (sortDir == null) {  sortDir = 'asc'; }  
       
        return sortDir;
      }
        
        set;
    }
    
    public String sortField {
    get  { if (sortField == null) {sortField = 'Appointment_Type__c'; } 
     
     return sortField; 
     }
   
    set;
    }
    
    public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
      }
      
    public apposearchController() {
    //delete(soql);
    soql = 'select Appointment_Type__c, Client__c, Start_Date__c, Status__c, Client_First_Name__c from Appointment1__c where Client_First_Name__c!= null';
    System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++Appoinment '+ Appoinment);
    System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++'+ soql  );
    runQuery();
      }
        
     public void toggleSort() 
    {
        sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
         
        runQuery();
        
    }

  //  public List<Appointment1__c> appo {get;set;}

    public String getStatus() {
        return null;
    }


    public void runQuery() {
         try
     {
     string a=soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20';
     system.debug(a);
      Appoinment = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
      System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++contacts '+ Appoinment);
     } 
    catch (Exception e) 
    {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }
 
   }
   
    public PageReference runSearch() 
    {
    
     String AppoinmentType;
     String Clint;
     string StartDate;
     String Status;
        
     AppoinmentType = Apexpages.currentPage().getParameters().get('AppoinmentType');
     System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++AppoinmentType '+ AppoinmentType);
     Clint = Apexpages.currentPage().getParameters().get('Clint');
     System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++Clint '+ Clint);
     
    // StartDate = Apexpages.currentPage().getParameters().get('StartDate');
   //  Datetime myDate = datetime.valueOf(StartDate);
   //  System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++PaccountName '+ StartDate);
  //  String technology = Apexpages.currentPage().getParameters().get('technology');
 
    soql = 'select Appointment_Type__c, Client__c, Start_Date__c, Status__c, Client_First_Name__c from Appointment1__c where Client_First_Name__c != null';
   
    if (!AppoinmentType.equals(''))
      soql += ' and Appointment_Type__c  LIKE \''+String.escapeSingleQuotes(AppoinmentType)+'%\'';
      System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++AppoinmentType '+ AppoinmentType);
    if (!Clint.equals(''))
      soql += ' and Client_First_Name__c  LIKE \''+String.escapeSingleQuotes(Clint)+'%\'';
      System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++Clint '+ Clint);
    // if (!myDate.equals(''))
    //  soql += ' and Start_Date__c LIKE \''+Datetime.escapeSingleQuotes(myDate)+'%\'';  
    //  System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++accountName'+ StartDate);
     if (!Status.equals(''))
      soql += ' and Status__c includes (\''+Status+'\')'; 
      System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++Status'+ Status);
      
        runQuery();
        return null;
     }   
        public List<String> Status
        {
            get 
            {
            if (Status == null) 
            {
     
            Status = new List<String>();
            Schema.DescribeFieldResult field = Appointment1__c.Status__c.getDescribe();
     
            for (Schema.PicklistEntry f : field.getPicklistValues())
              Status.add(f.getLabel());
     
          }
          return Status;          
        }
        set;
        
    }

}

 This is how i did. 

The problem is in :

if (!myDate.equals(''))
soql += ' and Start_Date__c LIKE \''+Datetime.escapeSingleQuotes(myDate)+'%\'';    System.debug('++++++++++++++++++++++++++++++++++++++++++++++++++++++++accountName'+ StartDate);

 please help me 

 

Thanks 

Anuraj

  • October 11, 2011
  • Like
  • 0

Hi All,

 

Any Idea How and where the content files are managed salesforce stores?

 

When I searched it says Files are stored in fully searchable file repositories known as workspaces.

 

But My question is what is mean by file repositories ? Where files actually stored is it in any objects like Attachment and Document object. When I searched all the object related to Content (contentworkspace,contentworkspaceDoc, content Doc)   there is no field which can store BLOB values.

 

Thanks in Advance

Anoop

  • May 23, 2011
  • Like
  • 0

Hi,

 

I have a 80 Accounts in my Account Object, where i need to display all the Accounts on Visualforce Page.

I used dataList Component and displayed all the 80 Accounts.

 

But the main requirement is, i need to select only 20 Accounts randomly and display those random 20 Accounts on Visualforce Page.

 

So, how do i write a random function in Apex in order to pick 20 random Accounts out of 80?

  • May 04, 2011
  • Like
  • 0