• Bhagyashree Shinde 8
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
A custom object "Participant"
In the object, a custom field, "Status" with two options: Participant or Applicant.

Under the Applicant status, only some of the custom fields are visible, eg:
Contact Info
Passport Number
Identity Number has an two option: Addhar No and Pan No
If pan no is selected output field for it should display or vise varsa.

Under the Participant status, the same custom fields and more are visible:
Contact Info
Passport number
T Shirt size
Medical/illness disclosure 
 

Hi All,

 

I am getting 'System.LimitException: Apex CPU time limit exceeded' error while reading and parsing XML as web service response.Debug log jhas reached its maximum size.

 

Below is my class:

 

public class readXMLResponseAndMapXMLDom{

 

public List<SiteSolutionProperty> getMap(){

Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('URL'); // did not include the actual URL; conncetion is successful.
req.setMethod('GET');
HttpResponse res = http.send(req);
List<XmlDom.Element> result1 = new List<XmlDom.Element>();
List<SiteSolutionProperty> result2 = new List<SiteSolutionProperty>();
SiteSolutionProperty ssp;
List<SiteSolutionPropertyDetails> finalResult = new List<SiteSolutionPropertyDetails>();
Integer counter = 0;
// create the xml doc that will contain the results of the REST operation

/********* USING XMLDOM ******/
XmlDom doc = new XmlDom(res.getBody());
// process the results
//System.debug('Total Collection size ---'+doc.getElementsByTagName('ClassBrokerAvailabilities').size());
system.debug('Limits.getHeapSize()'+Limits.getHeapSize());
for (XmlDom.Element element: doc.getElementsByTagName('ClassBrokerAvailabilities')){
ssp = new SiteSolutionProperty();
//element.textContent()
if(element.getElementsByTagName('BuildingKey') !=null){
//System.out.println("IF child name "+element.getElementsByTagName("BuildingKey").item(0).getTextContent());
ssp.setBuildingKey(element.getElementsByTagName('BuildingKey').get(0).textContent());
}
if(element.getElementsByTagName('AddressLine2') !=null){
ssp.setAddressLine2(element.getElementsByTagName('AddressLine2').get(0).textContent());
}
if(element.getElementsByTagName('BuildingName') !=null){
ssp.setBuildingName(element.getElementsByTagName('BuildingName').get(0).textContent());
}
/*if(element.getElementsByTagName('BuildingOwner') !=null){
ssp.setBuildingOwner(element.getElementsByTagName('BuildingOwner').get(0).textContent());
}*/

/*if(element.getElementsByTagName('BuildingStatus') !=null){
ssp.setBuildingStatus(element.getElementsByTagName('BuildingStatus').get(0).textContent());
}*/
if(element.getElementsByTagName('City_State') !=null){
ssp.setCity_State(element.getElementsByTagName('City_State').get(0).textContent());
}
/*if(element.getElementsByTagName('DateBuilt') !=null){
ssp.setDateBuilt(element.getElementsByTagName('DateBuilt').get(0).textContent());
}*/
/*if(element.getElementsByTagName('ForSale') !=null){
ssp.setForSale(element.getElementsByTagName('ForSale').get(0).textContent());
}*/
if(element.getElementsByTagName('LeasingAgent') !=null){
ssp.setLeasingAgent(element.getElementsByTagName('LeasingAgent').get(0).textContent());
}
if(element.getElementsByTagName('MarketName') !=null){
ssp.setMarketName(element.getElementsByTagName('MarketName').get(0).textContent());
}
/*if(element.getElementsByTagName('PropertyClass') !=null){
ssp.setPropertyClass(element.getElementsByTagName('PropertyClass').get(0).textContent());
}*/
if(element.getElementsByTagName('Recordnumber') !=null){
ssp.setRecordnumber(element.getElementsByTagName('Recordnumber').get(0).textContent());
}
if(element.getElementsByTagName('Rent') !=null){
ssp.setRent(element.getElementsByTagName('Rent').get(0).textContent());
}
if(element.getElementsByTagName('Rentable') !=null){
ssp.setRentable(element.getElementsByTagName('Rentable').get(0).textContent());
}
/*if(element.getElementsByTagName('SubMarket') !=null){
ssp.setSubMarket(element.getElementsByTagName('SubMarket').get(0).textContent());
}*/
/*if(element.getElementsByTagName('Vacant') !=null){
ssp.setVacant(element.getElementsByTagName('Vacant').get(0).textContent());
}*/
result2.add(ssp);

}

return result2;
}


}

 

and the Vf page is below:

 

<apex:page controller="readXMLResponseAndMapXMLDom" standardStylesheets="false" sidebar="false">
     <apex:form >
          <apex:pageBlock >
           <!-- section for button Add Property -->
               <apex:pageBlockButtons > 
                   <apex:commandButton value="Add Selected Property" action="{!propertySelected}" rerender="table"/> 
               </apex:pageBlockButtons>    
              <apex:pageBlockTable value="{!MAP}" var="propdetails" id="table">
                  <apex:column >
                      <!-- This is our select checkbox to select Properties data -->
                      <apex:inputCheckbox value="{!propdetails.selected}"/>
                  </apex:column>
                  <!-- Site Property Solution Details --> 
                  <!-- <apex:column headerValue="Recordnumber"  value="{!propdetails.Recordnumber}" /> -->
                  <apex:column headerValue="BuildingKey"  value="{!propdetails.BuildingKey}" />                  
                 <!--  <apex:column headerValue="BuildingName"  value="{!propdetails.BuildingName}" />
                  <apex:column headerValue="AddressLine2"  value="{!propdetails.AddressLine2}" />
                  <apex:column headerValue="City_State"  value="{!propdetails.City_State}" />
                  <apex:column headerValue="MarketName"  value="{!propdetails.MarketName}" />
                  <apex:column headerValue="Rentable"  value="{!propdetails.Rentable}" />
                  <apex:column headerValue="Vacant"  value="{!propdetails.Vacant}" /> 
                  <apex:column headerValue="PropertyClass"  value="{!propdetails.PropertyClass}" />
                  <apex:column headerValue="Rent"  value="{!propdetails.Rent}" />                  
                  <apex:column headerValue="LeasingAgent"  value="{!propdetails.LeasingAgent}" />
                  <apex:column headerValue="SubMarket"  value="{!propdetails.SubMarket}" />
                  <apex:column headerValue="BuildingType"  value="{!propdetails.BuildingType}" />
                  <apex:column headerValue="BuildingStatus"  value="{!propdetails.BuildingStatus}" />
                  <apex:column headerValue="DateBuilt"  value="{!propdetails.DateBuilt}" />
                  <apex:column headerValue="ForSale"  value="{!propdetails.ForSale}" />
                  <apex:column headerValue="BuildingOwner"  value="{!propdetails.BuildingOwner}" /> -->                      
    
              </apex:pageBlockTable>
          </apex:pageBlock>
          <apex:panelGrid columns="4">
              <apex:commandLink action="{!first}">First</apex:commandlink>
              <apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink>
              <apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink>
              <apex:commandLink action="{!last}">Last</apex:commandlink>
          </apex:panelGrid>
      </apex:form>
  </apex:page>




  • November 07, 2013
  • Like
  • 0