• sfdc webservices
  • NEWBIE
  • 0 Points
  • Member since 2015

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

In Activity object have two lookup fields like CASE and Contacts

Whenever user select a case how to populate this case related account contacts in contact lookup?

Thanks,

 

As I've seen on here a couple times, I'm trying to do an HTTP request and grab the xml data returned from google.  However, I've hit a wall while reading up on these things (I've been teaching myself coding for about 3 weeks now so sorry if this is a simple matter).  I think I have my HTTP request working and I'm attempting to grab the entire XML document and list it in a text box while also specifically grabbing the Longitude and Lattitude.  My overall goal is to type in a city and state but I want to just get it working before I dive into that (that's why it is commented out).  Honestly I think I'm on the right track buy having difficulty transcribing the info into a visualforce page.  Here's my attempted code:

 

public class interview6 {

    public String city {get;set;}
    public String state {get;set;}
    
public void Coordinates()
{
            Http http = new Http();
            HttpRequest req = new HttpRequest();
            String url = 'http://maps.googleapis.com/maps/api/geocode/xml?address=Kennesaw,+GA&sensor=false';
            // generate the url for the request
            //String url = 'http://maps.google.com/maps/api/geocode/xml?address='+ EncodingUtil.urlEncode(city,'UTF-8')+',+'
                //+ EncodingUtil.urlEncode(state,'UTF-8')
               // +'&sensor=false';
            // set the method
            req.setMethod('GET');
            // add the endpoint to the request
            req.setEndpoint(url);
HttpResponse res = http.send(req);
string responseBody = res.getBody().replace('\n','');
 string longitude;
 string latitude;
dom.Document doc = res.getBodyDocument();
//geometry
dom.XmlNode location = doc.getRootElement().getChildElement('result',null).getChildElement('geometry',null).getChildElement('location',null);         

longitude = location.getChildElement('lng', null).getText();
latitude = location.getChildElement('lat', null).getText();

    }

}

 

<apex:page controller="interview6">
  <apex:sectionHeader title="Interview Six"/>
    <apex:form >
        <apex:pageBlock >
          <apex:pageBlockSection title="Input" Columns="1">
            <apex:pageBlockSectionItem >
                  <apex:outputLabel for="City">City</apex:outputLabel>
               <apex:panelGroup >
                  <apex:inputText id="City" value="{!city}"/>
               </apex:panelGroup>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                 <apex:outputLabel for="State">State</apex:outputLabel>
               <apex:panelGroup >
                 <apex:inputText id="State" value="{!State}"/>
               </apex:panelGroup>
            </apex:pageBlockSectionItem>
         </apex:pageBlockSection>
         
         <apex:pageblockSection title="Output" Columns="1">
            <apex:pageBlockSectionItem >
                  <apex:outputLabel for="HTTP Response">HTTP Response</apex:outputLabel>
               <apex:panelGroup >
                  <apex:InputTextarea Cols="40" rows="20" />
               </apex:panelGroup>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                  <apex:outputLabel for="Lattitude">Lattitude</apex:outputLabel>
               <apex:panelGroup >
                  <apex:InputText id="Lattitude" />
               </apex:panelGroup>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                 <apex:outputLabel for="Longitude">Longitude</apex:outputLabel>
               <apex:panelGroup >
                 <apex:InputText id="Longitude" />
               </apex:panelGroup>
            </apex:pageBlockSectionItem>
         </apex:pageBlockSection>                 
       </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

Again I'm sure there are some issues with the above sample, but if I could just get some help with displaying the entire code in the text box I feel I could work from there without much issue.  Thanks for taking the time to look.