• Sugandhi Verma
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 28
    Replies
How to enable self registration in Customer Community in Developer Organisation? 
I am following these steps but it fails every time.
Set up-All Community- Manage-
Administration-Login & Registration- Enabling the Checkbox "allow external user to self register"
While selecting Account , there is no account available in lookup.
Can anybody guide how to enable self registration for customer community?? 
Hiii Experts,

I want to know that how to update 2 fields of 2 different object when the if condition is true in 1 workflow in salesforce????
 
if condition is==> if(system.date()==custom_object3__c.field3__c)

 if condition is true==> want to perform:
custom_object2__c.field2__c=(custom_object2__c.field2__c-1) custom_object1__c.field1__c=(custom_object1__c.field1__c-1)

if condition is false==> want to perform:
custom_object2__c.field2__c=custom_object2__c.field2__c custom_object1__c.field1__c=custom_object1__c.field1__c

how to do this in 1 workflow in formula editor????
 
Hiii,

I am adding the field value  with the apex:variable but getting the error--"Incorrect parameter type for operator '+'. Expected Text, received Number" Below is my code,please helppp:
<apex:variable value="{!0.00}" var="total1"/>
        <apex:pageBlock >
                     <apex:pageBlockTable title="Your Item" value="{!selectedWrapperList}" var="wrapRec" rendered="{!selectedList}" >
                    
 <apex:column value="{!wrapRec.Name}" />
              
               <apex:column ><apex:outputField value="{!wrapRec.T_Price__c}" />
               <apex:variable var="total1" value="{! total1 + wrapRec.T_Price__c}" />

        <!-- Footer of the first Cell -->>
        <apex:facet name="footer">
            Total:{!total1}  <span class="t1"></span>
        </apex:facet>
               </apex:column>
 </apex:pageBlockTable> 
             
              </apex:pageBlock>

   <script>
   document.getElementsByClassName('t1')[0].innerHTML = '{!total1}';
   </script>

 
Hi,
Please help me with the below scenario, I have Visualforce page through which I can select different checkbox value  and display the selected item on another visualforce  page without storing it in the object. My Requirment is when the multiple checkboxes are selected and Save botton is clicked, then the checked values need to be display on another page.
Selected Checkbox values should be store in Cookie.

Please help me on this scenario. ThankYou.
Below is my Visualforce Page.
<apex:page controller="TourHomeContrllr1" standardStylesheets="false" showHeader="false">
<apex:repeat value="{!naamClicked}" var="t">
    <div class="row">
    <div class="col-md-12 maincol" data-toggle="modal" data-target="#myModal" id="id1" >
                       
                     <div style="float:right;margin-top:5px;" class="img-responsive">
		<apex:outputField value="{!t.Tour_Place_Images__c}" style="width:200px;height:200px;" > </apex:outputField></div>
<br></br>                 
                <apex:form >    
                        <div style="float:right;"><apex:inputField value="{!t.Select__c}"></apex:inputField>
                        </div><br></br>   
                </apex:form>           
      </div> 
     </div>
     </apex:repeat>
 <apex:pageBlock >
                  <apex:form >
                  <apex:pageBlockSection >
                     <apex:commandButton action="{!addToCart}" value="Book Place" styleClass="btn btn-primary" rerender="select_places"/> </apex:pageBlockSection>
                         </apex:form>
                </apex:pageBlock>
                
                     <apex:pageBlock title="Your Places" id="select_places">
 <apex:outputText value="{!cartContents}" escape="true"/> </apex:pageBlock>
</apex:page>

 

page is:

<apex:page controller="TourHomeContrllr1" standardStylesheets="false" showHeader="false">
<apex:repeat value="{!naamClicked}" var="t">
    <div class="row">
    <div class="col-md-12 maincol" data-toggle="modal" data-target="#myModal" id="id1" >
                       
                     <div style="float:right;margin-top:5px;" class="img-responsive">
		<apex:outputField value="{!t.Tour_Place_Images__c}" style="width:200px;height:200px;" > </apex:outputField></div>
<br></br>                 
                <apex:form >    
                        <div style="float:right;"><apex:inputField value="{!t.Select__c}"></apex:inputField>
                        </div><br></br>   
                </apex:form>           
      </div> 
     </div>
     </apex:repeat>
 <apex:pageBlock >
                  <apex:form >
                  <apex:pageBlockSection >
                     <apex:commandButton action="{!addToCart}" value="Book Place" styleClass="btn btn-primary" rerender="select_places"/> </apex:pageBlockSection>
                         </apex:form>
                </apex:pageBlock>
                
                     <apex:pageBlock title="Your Places" id="select_places">
 <apex:outputText value="{!cartContents}" escape="true"/> </apex:pageBlock>
</apex:page>



controller is:

public class TourHomeContrllr1 {
  public List<Tour_Places__c> tourInformation{ get; set;}
public List<Tour_Places__c> getNaamClicked() {
        tourInformation=[Select Name,Place__c,Tour_Place_Images__c,Select__c,Tour_Name__c,Tour_Price__c from Tour_Places__c where Tour_Name__c in :[Select Name from Tours__c where Id =:ApexPages.currentPage().getParameters().get('oid')] ];
    return tourInformation;
    }   
  public List<Tour_Places__c> bookInformation{ get; set;}
public List<Tour_Places__c> getSelectClicked() {
        bookInformation=[Select Name,Place__c,Tour_Place_Images__c,Select__c,Tour_Name__c,Tour_Price__c from Tour_Places__c where Tour_Name__c in :[Select Name from Tours__c where Id =:ApexPages.currentPage().getParameters().get('oid')] ];
    return bookInformation;
    }
public list<Tour_Places__c> tsel=new list<Tour_Places__c>();
    Map< String,Boolean> select_places = new Map<String,Boolean>(); 
public PageReference addToCart() {
    PageReference pageRef = new PageReference('/apex/cart');
    for(Tour_Places__c p :tourInformation ) {
        if(p.Select__c=TRUE){ 
            select_places.put(p.Place__c, p.Select__c);
            cookieJar c = new cookieJar(p.Place__c, p.Name, String.valueOf(p.Select__c)); 
           }
    }   
    pageRef.setRedirect(true);
    // return pageRef;
    return null;
}
public String getCartContents() {
 if(0 == select_places.size()) {
        return '(cart is empty)';
    }
    String msg = '<ul>\n';
    for(String id : select_places.keyset()) {
    msg += '<li>';
        msg +=  id + ' (' + select_places.get(id) + ')';
        msg += '</li>\n';
    }
    msg += '</ul>';
     Cookie theCookie;
    theCookie = ApexPages.currentPage().getCookies().get('Place__c');
    if(theCookie != null)  
    msg +=theCookie.getValue();
    theCookie = ApexPages.currentPage().getCookies().get('Name');
    if(theCookie != null)  
    msg +=theCookie.getValue();

    theCookie = ApexPages.currentPage().getCookies().get('Select__c');
    if(theCookie != null)  
    msg += theCookie.getValue();
    return msg;
}
public class cookieJar {
        public cookieJar(String place, String Name, String tselect) {
            Cookie pplace = new Cookie('place', place,null,315569260,false);
            Cookie pName = new Cookie('Name', Name,null,315569260,false);
            Cookie qselect = new Cookie('tselect', tselect,null,315569260,false);
            //Set the page cookies using the setCookies() method
            ApexPages.currentPage().setCookies(new Cookie[]
            {pplace, pName, qselect} );
        }
    }//end cookieJar inner class
}


please let me know how to store the selected items only in the cookie...and send the values to the another page.
Hiii Plz Help!!!!!!!!!


I want user to select some items using checkbox field of the object on 1st visualforce page.Then i want it to show the selected items on another visualforce page. Please replyyy.
Hii,
I am not able to see menu and tool bar in rich text field. Plz help.User-added image
Hii,
I am not able to see menu and tool bar in rich text field. Plz help.User-added image

Hii, I have a page and class.I have the field location of geolocation type.I want to show the location on GMAP when i search for a particular thing.Like when i select 'India', i am getting the records of having address in India But not getting their location on GMAP. My code is: 
Page:
 <apex:page controller="tourmapController1" tabStyle="Accomodation__c" action="{!find}" id="page">  
  <head>      
  <style>       
      div #map_canvas { height: 400px; }      
  </style>     
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>  
  </head>   
  <apex:sectionHeader title="Hello StackOverflow!" subtitle="Accomodation full text search + Google Maps integration" />  
  <apex:pageMessages /> 
    <apex:form id="form">       
  <apex:pageBlock id="searchBlock">       
      <apex:inputText value="{!searchText}" />    
        <apex:commandButton value="Search" action="{!find}"/>    
        <p>Examples: <a href="/apex/{!$CurrentPage.Name}?q=USA">"USA"</a>, "Singapore", "Uni", "(336) 222-7000". If it works in the global search box, it will work here.</p>    
    </apex:pageBlock>     
    <apex:pageBlock title="Found {!accod.size} Accomodation__c..." rendered="{!NOT(ISNULL(accod)) && accod.size > 0}" id="resultsBlock">             <apex:pageBlockButtons location="top">    
            <apex:commandButton value="Clear cached locations" title="Click if you want to set 'null' as geolocation info for all these accomodations" action="{!clearGeocodedData}" />   
          </apex:pageBlockButtons>        
    <apex:pageBlockTable value="{!accod}" var="a" id="accod">    
            <apex:column headerValue="{!$ObjectType.Accomodation__c.fields.Name.label}">         
            <apex:outputLink value="../{!a.Id}">{!a.Name}</apex:outputLink>    
            </apex:column>                 
<apex:column headerValue="Address">           
          {!a.Street_Address__c} {!a.City__c} {!a.Country__c}      
          </apex:column>               
  <apex:column value="{!a.Accomodation_Name__c}"/>             
    <apex:column headerValue="Location (retrieved from DB or geocoded server-side)">       
              {!a.Location__Latitude__s}, {!a.Location__Longitude__s}           
      </apex:column>            
</apex:pageBlockTable>           
  <apex:pageBlockSection columns="1" id="mapSection">       
          <div id="map_canvas" />         
    </apex:pageBlockSection>            
<apex:pageBlockSection title="Click to show/hide what was geocoded server-side and passed to JS for further manipulation" columns="1" id="debugSection">       
         1 {!debugAccomodationJson}        
    </apex:pageBlockSection>            1      
    </apex:pageBlock>   
  </apex:form>    
<script type="text/javascript">   
  twistSection(document.getElementById('page:form:resultsBlock:debugSection').childNodes[0].childNodes[0]); // initially hide the debug section     var accod = {!accodJson};  
      var coords = [];                
    var requestCounter = 0;    
var markers = [];                  // Red things we pin to the map.  
  var balloon = new google.maps.InfoWindow();   
  function geocodeClientSide() {    
    for(var i = 0; i < accod.length; i++) {       
      if(accod[i].Location__Latitude__s != null && accod[i].Location__Longitude__s != null) {     
            coords.push(new google.maps.LatLng(accod[i].Location__Latitude__s, accod[i].Location__Longitude__s));      
      } 
else {             
    ++requestCounter;              
  var address = accod[i].Street_Address__c + ' ' + accod[i].City__c + ' ' + accod[i].Country__c;    
            var geocoder = new google.maps.Geocoder();    
            if (geocoder) {        
            geocoder.geocode({'address':address},
function (results, status) {        
                if (status == google.maps.GeocoderStatus.OK) {         
                    coords.push(results[0].geometry.location);            
            } 
else {                          
  var pTag = document.createElement("p");           
                  pTag.innerHTML = status;            
                document.getElementById('log').appendChild(pTag);       
                  }                      
  if(--requestCounter == 0) {                     
        drawMap();                
        }              
      });            
    }       
      }    
    }            
    if(requestCounter == 0) {      
      drawMap();     
    }   
  }    
function drawMap(){  
      var mapOptions = {        center: coords[0],            zoom: 3,             mapTypeId: google.maps.MapTypeId.ROADMAP         };   
     var map = new google.maps.Map(document.getElementById("map_canvas"),  mapOptions);   
      for(var i = 0; i < coords.length; ++i){      
      var marker = new google.maps.Marker({map: map, position: coords[i], title:accod[i].Name, zIndex:i});    
        google.maps.event.addListener(marker, 'click', function() {            
    var index = this.zIndex;               
  balloon.content = '<b>'+accod[index].Name + '</b><br/>' + accod[index].Accomodation_Name__c + '<br/>' + accod[index].City__c;                 balloon.open(map,this);    
        });      
      markers.push(marker);    
    }   
  }   
  geocodeClientSide();   
  </script> 
</apex:page> 


Class: 
public with sharing class tourmapController1 {  
  public String accodJson { get; set; }  
public String searchText {get;set;}
public List<Accomodation__c> accod{get; private set;}
public static final String GEOCODING_URI_BASE = 'https://maps.googleapis.com/maps/api/geocode/json?sensor=true&address='; 
public static final Integer MAX_CALLOUTS_FROM_APEX = 3; // Limits.getLimitCallouts() 
public tourmapController1(){     
searchText = ApexPages.currentPage().getParameters().get('q'); 

public void find() {   
  if(searchText != null && searchText.length() > 1){     
    List<List<SObject>> results = [FIND :('*' + searchText + '*') IN ALL FIELDS RETURNING              Accomodation__c (Id, Name,Accomodation_Name__c,                 Street_Address__c,City__c,PostalCode__c, State__c, Country__c,                  Location__Latitude__s, Location__Longitude__s)             ];   
      accod = (List<Accomodation__c>)results[0];    
    if(accod.isEmpty()){       
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'No matches for "' + searchText + '"'));   
      } 
else {       
      serverSideGeocode();      
  }   
  } 
else {   
      if(accod != null) {       
      accod.clear();     
    }        
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Please provide at least 2 characters for the search.'));  
  } } 
public void clearGeocodedData(){ 
    for(Accomodation__c a : accod){     
    a.Location__Latitude__s = a.Location__Longitude__s = null;  
  }    
Database.update(accod, false);     
accod.clear(); 

public String getAccomodationJson(){  
  return JSON.serialize(accod);

public String getDebugAccomodationJson(){ 
    return JSON.serializePretty(accod); 

private void serverSideGeocode(){  
  List<Accomodation__c> accodToUpdate = new List<Accomodation__c>();   
  Http h = new Http();  
    HttpRequest req = new HttpRequest(); 
    req.setMethod('GET');    
  req.setTimeout(10000);  
  for(Accomodation__c a : accod){  
      if((a.Location__Latitude__s == null || a.Location__Longitude__s == null)){     
        String address = a.Street_Address__c != null ? a.Street_Address__c + ' ' : '' +                 a.City__c != null ? a.City__c + ' ' : '' +                 a.State__c != null ? a.State__c + ' ' : '' +                 a.PostalCode__c != null ? a.PostalCode__c + ' ' : '' +                 a.Country__c != null ? a.Country__c : '';    
        if(address != ''){        
        req.setEndpoint(GEOCODING_URI_BASE + EncodingUtil.urlEncode(address, 'UTF-8'));         
        try{      
              HttpResponse res = h.send(req);               
      GResponse gr = (GResponse) JSON.deserialize(res.getBody(), tourmapController1.GResponse.class);  
                  if(gr.status == 'OK'){       
                  LatLng ll = gr.results[0].geometry.location;            
            a.Location__Latitude__s = ll.lat;             
            a.Location__Longitude__s = ll.lng;       
                  accodToUpdate.add(a);          
          } 
else {            
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Geocoding of "' + address + '" failed:' + gr.status));  
                  }          
      }
catch(Exception e){       
              ApexPages.addMessages(e);      
          }      
      }                
          if(Limits.getCallouts() == MAX_CALLOUTS_FROM_APEX) {            
    break;         
    }     
    }   
  }   
  if(!accodToUpdate.isEmpty()) {  
      Database.update(accodToUpdate, false); // some data in Developer editions is invalid (on purpose I think).        

  } }
public class GResponse{   
  public String status; 
    public GComponents[] results;

public class GComponents{    
public String formatted_address;  
 public GGeometry geometry; 

public class GGeometry {   
  public LatLng location; 

public class LatLng{  
  public Double lat, lng;
}
​ }

Hii, I have a page and class.I have the field location of geolocation type.I want to show the location on GMAP when i search for a particular thing.Like when i select 'India', i am getting the records of having address in India But not getting their location on GMAP. My code is: 
Page:
 <apex:page controller="tourmapController1" tabStyle="Accomodation__c" action="{!find}" id="page">  
  <head>      
  <style>       
      div #map_canvas { height: 400px; }      
  </style>     
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>  
  </head>   
  <apex:sectionHeader title="Hello StackOverflow!" subtitle="Accomodation full text search + Google Maps integration" />  
  <apex:pageMessages /> 
    <apex:form id="form">       
  <apex:pageBlock id="searchBlock">       
      <apex:inputText value="{!searchText}" />    
        <apex:commandButton value="Search" action="{!find}"/>    
        <p>Examples: <a href="/apex/{!$CurrentPage.Name}?q=USA">"USA"</a>, "Singapore", "Uni", "(336) 222-7000". If it works in the global search box, it will work here.</p>    
    </apex:pageBlock>     
    <apex:pageBlock title="Found {!accod.size} Accomodation__c..." rendered="{!NOT(ISNULL(accod)) && accod.size > 0}" id="resultsBlock">             <apex:pageBlockButtons location="top">    
            <apex:commandButton value="Clear cached locations" title="Click if you want to set 'null' as geolocation info for all these accomodations" action="{!clearGeocodedData}" />   
          </apex:pageBlockButtons>        
    <apex:pageBlockTable value="{!accod}" var="a" id="accod">    
            <apex:column headerValue="{!$ObjectType.Accomodation__c.fields.Name.label}">         
            <apex:outputLink value="../{!a.Id}">{!a.Name}</apex:outputLink>    
            </apex:column>                 
<apex:column headerValue="Address">           
          {!a.Street_Address__c} {!a.City__c} {!a.Country__c}      
          </apex:column>               
  <apex:column value="{!a.Accomodation_Name__c}"/>             
    <apex:column headerValue="Location (retrieved from DB or geocoded server-side)">       
              {!a.Location__Latitude__s}, {!a.Location__Longitude__s}           
      </apex:column>            
</apex:pageBlockTable>           
  <apex:pageBlockSection columns="1" id="mapSection">       
          <div id="map_canvas" />         
    </apex:pageBlockSection>            
<apex:pageBlockSection title="Click to show/hide what was geocoded server-side and passed to JS for further manipulation" columns="1" id="debugSection">       
         1 {!debugAccomodationJson}        
    </apex:pageBlockSection>            1      
    </apex:pageBlock>   
  </apex:form>    
<script type="text/javascript">   
  twistSection(document.getElementById('page:form:resultsBlock:debugSection').childNodes[0].childNodes[0]); // initially hide the debug section     var accod = {!accodJson};  
      var coords = [];                
    var requestCounter = 0;    
var markers = [];                  // Red things we pin to the map.  
  var balloon = new google.maps.InfoWindow();   
  function geocodeClientSide() {    
    for(var i = 0; i < accod.length; i++) {       
      if(accod[i].Location__Latitude__s != null && accod[i].Location__Longitude__s != null) {     
            coords.push(new google.maps.LatLng(accod[i].Location__Latitude__s, accod[i].Location__Longitude__s));      
      } 
else {             
    ++requestCounter;              
  var address = accod[i].Street_Address__c + ' ' + accod[i].City__c + ' ' + accod[i].Country__c;    
            var geocoder = new google.maps.Geocoder();    
            if (geocoder) {        
            geocoder.geocode({'address':address},
function (results, status) {        
                if (status == google.maps.GeocoderStatus.OK) {         
                    coords.push(results[0].geometry.location);            
            } 
else {                          
  var pTag = document.createElement("p");           
                  pTag.innerHTML = status;            
                document.getElementById('log').appendChild(pTag);       
                  }                      
  if(--requestCounter == 0) {                     
        drawMap();                
        }              
      });            
    }       
      }    
    }            
    if(requestCounter == 0) {      
      drawMap();     
    }   
  }    
function drawMap(){  
      var mapOptions = {        center: coords[0],            zoom: 3,             mapTypeId: google.maps.MapTypeId.ROADMAP         };   
     var map = new google.maps.Map(document.getElementById("map_canvas"),  mapOptions);   
      for(var i = 0; i < coords.length; ++i){      
      var marker = new google.maps.Marker({map: map, position: coords[i], title:accod[i].Name, zIndex:i});    
        google.maps.event.addListener(marker, 'click', function() {            
    var index = this.zIndex;               
  balloon.content = '<b>'+accod[index].Name + '</b><br/>' + accod[index].Accomodation_Name__c + '<br/>' + accod[index].City__c;                 balloon.open(map,this);    
        });      
      markers.push(marker);    
    }   
  }   
  geocodeClientSide();   
  </script> 
</apex:page> 


Class: 
public with sharing class tourmapController1 {  
  public String accodJson { get; set; }  
public String searchText {get;set;}
public List<Accomodation__c> accod{get; private set;}
public static final String GEOCODING_URI_BASE = 'https://maps.googleapis.com/maps/api/geocode/json?sensor=true&address='; 
public static final Integer MAX_CALLOUTS_FROM_APEX = 3; // Limits.getLimitCallouts() 
public tourmapController1(){     
searchText = ApexPages.currentPage().getParameters().get('q'); 

public void find() {   
  if(searchText != null && searchText.length() > 1){     
    List<List<SObject>> results = [FIND :('*' + searchText + '*') IN ALL FIELDS RETURNING              Accomodation__c (Id, Name,Accomodation_Name__c,                 Street_Address__c,City__c,PostalCode__c, State__c, Country__c,                  Location__Latitude__s, Location__Longitude__s)             ];   
      accod = (List<Accomodation__c>)results[0];    
    if(accod.isEmpty()){       
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'No matches for "' + searchText + '"'));   
      } 
else {       
      serverSideGeocode();      
  }   
  } 
else {   
      if(accod != null) {       
      accod.clear();     
    }        
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Please provide at least 2 characters for the search.'));  
  } } 
public void clearGeocodedData(){ 
    for(Accomodation__c a : accod){     
    a.Location__Latitude__s = a.Location__Longitude__s = null;  
  }    
Database.update(accod, false);     
accod.clear(); 

public String getAccomodationJson(){  
  return JSON.serialize(accod);

public String getDebugAccomodationJson(){ 
    return JSON.serializePretty(accod); 

private void serverSideGeocode(){  
  List<Accomodation__c> accodToUpdate = new List<Accomodation__c>();   
  Http h = new Http();  
    HttpRequest req = new HttpRequest(); 
    req.setMethod('GET');    
  req.setTimeout(10000);  
  for(Accomodation__c a : accod){  
      if((a.Location__Latitude__s == null || a.Location__Longitude__s == null)){     
        String address = a.Street_Address__c != null ? a.Street_Address__c + ' ' : '' +                 a.City__c != null ? a.City__c + ' ' : '' +                 a.State__c != null ? a.State__c + ' ' : '' +                 a.PostalCode__c != null ? a.PostalCode__c + ' ' : '' +                 a.Country__c != null ? a.Country__c : '';    
        if(address != ''){        
        req.setEndpoint(GEOCODING_URI_BASE + EncodingUtil.urlEncode(address, 'UTF-8'));         
        try{      
              HttpResponse res = h.send(req);               
      GResponse gr = (GResponse) JSON.deserialize(res.getBody(), tourmapController1.GResponse.class);  
                  if(gr.status == 'OK'){       
                  LatLng ll = gr.results[0].geometry.location;            
            a.Location__Latitude__s = ll.lat;             
            a.Location__Longitude__s = ll.lng;       
                  accodToUpdate.add(a);          
          } 
else {            
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Geocoding of "' + address + '" failed:' + gr.status));  
                  }          
      }
catch(Exception e){       
              ApexPages.addMessages(e);      
          }      
      }                
          if(Limits.getCallouts() == MAX_CALLOUTS_FROM_APEX) {            
    break;         
    }     
    }   
  }   
  if(!accodToUpdate.isEmpty()) {  
      Database.update(accodToUpdate, false); // some data in Developer editions is invalid (on purpose I think).        

  } }
public class GResponse{   
  public String status; 
    public GComponents[] results;

public class GComponents{    
public String formatted_address;  
 public GGeometry geometry; 

public class GGeometry {   
  public LatLng location; 

public class LatLng{  
  public Double lat, lng;
}
​ }
i am not able to watch app setup option on my account to Enable 'Maps and Location Services'. Please give the details.
i am not able to watch app setup option on my account to Enable 'Maps and Location Services'. Please give the details.
Hii,
I have a page and class.I have the field location of geolocation type.I want to show the location on GMAP when i search for a particular thing.Like when i select 'India', i am getting the records of having address in India But not getting their location on GMAP.
My code is:

Page:
<apex:page controller="tourmapController1" tabStyle="Accomodation__c" action="{!find}" id="page">
    <head>
        <style>
            div #map_canvas { height: 400px; }
        </style>
        <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"></script>
    </head>
    <apex:sectionHeader title="Hello StackOverflow!" subtitle="Accomodation full text search + Google Maps integration" />
    <apex:pageMessages />
    <apex:form id="form">
        <apex:pageBlock id="searchBlock">
            <apex:inputText value="{!searchText}" />
            <apex:commandButton value="Search" action="{!find}"/>
            <p>Examples: <a href="/apex/{!$CurrentPage.Name}?q=USA">"USA"</a>, "Singapore", "Uni", "(336) 222-7000". If it works in the global search box, it will work here.</p>
        </apex:pageBlock>
        <apex:pageBlock title="Found {!accod.size} Accomodation__c..." rendered="{!NOT(ISNULL(accod)) && accod.size > 0}" id="resultsBlock">
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Clear cached locations" title="Click if you want to set 'null' as geolocation info for all these accomodations" action="{!clearGeocodedData}" />
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!accod}" var="a" id="accod">
                <apex:column headerValue="{!$ObjectType.Accomodation__c.fields.Name.label}">
                    <apex:outputLink value="../{!a.Id}">{!a.Name}</apex:outputLink>
                </apex:column>
                <apex:column headerValue="Address">
                    {!a.Street_Address__c} {!a.City__c} {!a.Country__c}
                </apex:column>
                <apex:column value="{!a.Accomodation_Name__c}"/>
                <apex:column headerValue="Location (retrieved from DB or geocoded server-side)">
                    {!a.Location__Latitude__s}, {!a.Location__Longitude__s}
                </apex:column>
            </apex:pageBlockTable>
            <apex:pageBlockSection columns="1" id="mapSection">
                <div id="map_canvas" />
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Click to show/hide what was geocoded server-side and passed to JS for further manipulation" columns="1" id="debugSection">
                <pre>{!debugAccomodationJson}</pre>
            </apex:pageBlockSection>
            <pre id="log"></pre>
        </apex:pageBlock>
    </apex:form>
    <script type="text/javascript">
    twistSection(document.getElementById('page:form:resultsBlock:debugSection').childNodes[0].childNodes[0]); // initially hide the debug section

    var accod = {!accodJson};    
    var coords = [];                
    var requestCounter = 0;

    var markers = [];                  // Red things we pin to the map.
    var balloon = new google.maps.InfoWindow(); 

    function geocodeClientSide() {
        for(var i = 0; i < accod.length; i++) {
            if(accod[i].Location__Latitude__s != null && accod[i].Location__Longitude__s != null) {
                coords.push(new google.maps.LatLng(accod[i].Location__Latitude__s, accod[i].Location__Longitude__s));
            } else {
                ++requestCounter;
                var address = accod[i].Street_Address__c + ' ' + accod[i].City__c + ' ' + accod[i].Country__c;
                var geocoder = new google.maps.Geocoder();
                if (geocoder) {
                    geocoder.geocode({'address':address}, function (results, status) {
                        if (status == google.maps.GeocoderStatus.OK) {
                            coords.push(results[0].geometry.location);
                        } else {
                            var pTag = document.createElement("p");
                            pTag.innerHTML = status;
                            document.getElementById('log').appendChild(pTag);
                        }
                        if(--requestCounter == 0) {
                            drawMap();
                        }
                    });
                }
            }
        }
      
        if(requestCounter == 0) {
            drawMap();
        }
    }

    function drawMap(){
        var mapOptions = {
            center: coords[0],
            zoom: 3,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"),  mapOptions);

        for(var i = 0; i < coords.length; ++i){
            var marker = new google.maps.Marker({map: map, position: coords[i], title:accod[i].Name, zIndex:i});

            google.maps.event.addListener(marker, 'click', function() {
                var index = this.zIndex;
                balloon.content = '<b>'+accod[index].Name + '</b><br/>' + accod[index].Accomodation_Name__c + '<br/>' + accod[index].City__c;
                balloon.open(map,this);
            });
            markers.push(marker);
        }
    }

    geocodeClientSide();
    </script>
</apex:page>

Class:
public with sharing class tourmapController1 {

    public String accodJson { get; set; }

 public String searchText {get;set;}
public List<Accomodation__c> accod{get; private set;}

public static final String GEOCODING_URI_BASE = 'https://maps.googleapis.com/maps/api/geocode/json?sensor=true&address=';

public static final Integer MAX_CALLOUTS_FROM_APEX = 3; // Limits.getLimitCallouts()

public tourmapController1(){
    searchText = ApexPages.currentPage().getParameters().get('q');
}

public void find() {
    if(searchText != null && searchText.length() > 1){
        List<List<SObject>> results = [FIND :('*' + searchText + '*') IN ALL FIELDS RETURNING 
            Accomodation__c (Id, Name,Accomodation_Name__c,
                Street_Address__c,City__c,PostalCode__c, State__c, Country__c, 
                Location__Latitude__s, Location__Longitude__s)
            ];
        accod = (List<Accomodation__c>)results[0];
        if(accod.isEmpty()){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'No matches for "' + searchText + '"'));
        } else {
            serverSideGeocode();
        }
    } else {
        if(accod != null) {
            accod.clear();
        }
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Please provide at least 2 characters for the search.'));
    }
}

public void clearGeocodedData(){
    for(Accomodation__c a : accod){
        a.Location__Latitude__s = a.Location__Longitude__s = null;
    }
    Database.update(accod, false);
    accod.clear();
}

public String getAccomodationJson(){
    return JSON.serialize(accod);
}
public String getDebugAccomodationJson(){
    return JSON.serializePretty(accod);
}

private void serverSideGeocode(){
    List<Accomodation__c> accodToUpdate = new List<Accomodation__c>();
    Http h = new Http();  
    HttpRequest req = new HttpRequest();
    req.setMethod('GET'); 
    req.setTimeout(10000);

    for(Accomodation__c a : accod){
        if((a.Location__Latitude__s == null || a.Location__Longitude__s == null)){
            String address = a.Street_Address__c != null ? a.Street_Address__c + ' ' : '' +
                a.City__c != null ? a.City__c + ' ' : '' +
                a.State__c != null ? a.State__c + ' ' : '' +
                a.PostalCode__c != null ? a.PostalCode__c + ' ' : '' +
                a.Country__c != null ? a.Country__c : '';
            if(address != ''){
                req.setEndpoint(GEOCODING_URI_BASE + EncodingUtil.urlEncode(address, 'UTF-8'));
                try{
                    HttpResponse res = h.send(req);
                    GResponse gr = (GResponse) JSON.deserialize(res.getBody(), tourmapController1.GResponse.class);
                    if(gr.status == 'OK'){
                        LatLng ll = gr.results[0].geometry.location;
                        a.Location__Latitude__s = ll.lat;
                        a.Location__Longitude__s = ll.lng;
                        accodToUpdate.add(a);
                    } else {
                        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Geocoding of "' + address + '" failed:' + gr.status));
                    }
                }catch(Exception e){
                    ApexPages.addMessages(e);
                }
            }
            
            if(Limits.getCallouts() == MAX_CALLOUTS_FROM_APEX) {
                break;
            }
        }
    }
    if(!accodToUpdate.isEmpty()) {
        Database.update(accodToUpdate, false); // some data in Developer editions is invalid (on purpose I think).
        // If update fails because "j.davis@expressl&amp;t.net" is not a valid Email, I want the rest to succeed
    }
}


public class GResponse{
    public String status;
    public GComponents[] results;
}
public class GComponents{
   public String formatted_address;
   public GGeometry geometry;
}
public class GGeometry {
    public LatLng location;
}
public class LatLng{
    public Double lat, lng;
}

}
hi, i want create 2 visualforce pages with a controller using custom object.In the first page, i want to select the one record and pass it's id to another visual force page which will show it's details using query string.But i am getting no result in 2nd page ,in the url i am getting the id but it is appending with AAK.

Please review my code.




1st Visualforce page:

<apex:page controller="MytranschController">

<apex:form >

<apex:dataList value="{!myaccounts}" var="tr">

<apex:outputField value="{!tr.Name}"> </apex:outputField><br></br>

<apex:outputLink onclick="accountClicked()"  value="/apex/secondpage" >

<apex:param name="oid" value="{!tr.Id}" assignTo="{!selectedAccount}"/>

View

</apex:outputLink>

</apex:dataList></apex:form>

</apex:page>







2nd Visualforce page:

<apex:page controller="MytranschController">

 <apex:outputPanel id="id1">

<apex:repeat value="{!contactsInformation}" var="t">

<apex:detail subject="{!$CurrentPage.parameters.oid}" relatedList="false" title="false" />

<p> <apex:outputField value="{!t.Name}"/> </p>

<p>

<apex:outputField value="{!t.Transp_Image__c}"> </apex:outputField></p>

</apex:repeat>

</apex:outputPanel>

</apex:page>




Class

public class MytranschController {

//String value = ApexPages.currentPage().getParameters().get(name);

public Id selectedAccount{get; set;}

    public List<Transportation_Mediums__c> contactsInformation{ get; set;}

    public List<Transportation_Mediums__c> getMyAccounts() {

        return [Select Id,Name,Trans_Image__c,Transportaion_Cost__c from Transportation_Mediums__c ];

    }

    public void accountClicked()

    {

    contactsInformation=[Select Name,Transp_Image__c from Transportation_Mediums__c where Id=:selectedAccount];

    }

}
hi, i want create 2 visualforce pages with a controller using custom object.In the first page, i want to select the one record and pass it's id to another visual force page which will show it's details using query string.But i am getting no result in 2nd page ,in the url i am getting the id but it is appending with AAK.

Please review my code.




1st Visualforce page:

<apex:page controller="MytranschController">

<apex:form >

<apex:dataList value="{!myaccounts}" var="tr">

<apex:outputField value="{!tr.Name}"> </apex:outputField><br></br>

<apex:outputLink onclick="accountClicked()"  value="/apex/secondpage" >

<apex:param name="oid" value="{!tr.Id}" assignTo="{!selectedAccount}"/>

View

</apex:outputLink>

</apex:dataList></apex:form>

</apex:page>







2nd Visualforce page:

<apex:page controller="MytranschController">

 <apex:outputPanel id="id1">

<apex:repeat value="{!contactsInformation}" var="t">

<apex:detail subject="{!$CurrentPage.parameters.oid}" relatedList="false" title="false" />

<p> <apex:outputField value="{!t.Name}"/> </p>

<p>

<apex:outputField value="{!t.Transp_Image__c}"> </apex:outputField></p>

</apex:repeat>

</apex:outputPanel>

</apex:page>




Class

public class MytranschController {

//String value = ApexPages.currentPage().getParameters().get(name);

public Id selectedAccount{get; set;}

    public List<Transportation_Mediums__c> contactsInformation{ get; set;}

    public List<Transportation_Mediums__c> getMyAccounts() {

        return [Select Id,Name,Trans_Image__c,Transportaion_Cost__c from Transportation_Mediums__c ];

    }

    public void accountClicked()

    {

    contactsInformation=[Select Name,Transp_Image__c from Transportation_Mediums__c where Id=:selectedAccount];

    }

}
hi, i want create 2 visualforce page with a controller using custom object.In the first page i want select the one record and pass it's id to another visual force page which will show it's details using query string.
Hiii Experts,

I want to know that how to update 2 fields of 2 different object when the if condition is true in 1 workflow in salesforce????
 
if condition is==> if(system.date()==custom_object3__c.field3__c)

 if condition is true==> want to perform:
custom_object2__c.field2__c=(custom_object2__c.field2__c-1) custom_object1__c.field1__c=(custom_object1__c.field1__c-1)

if condition is false==> want to perform:
custom_object2__c.field2__c=custom_object2__c.field2__c custom_object1__c.field1__c=custom_object1__c.field1__c

how to do this in 1 workflow in formula editor????
 
Hiii,

I am adding the field value  with the apex:variable but getting the error--"Incorrect parameter type for operator '+'. Expected Text, received Number" Below is my code,please helppp:
<apex:variable value="{!0.00}" var="total1"/>
        <apex:pageBlock >
                     <apex:pageBlockTable title="Your Item" value="{!selectedWrapperList}" var="wrapRec" rendered="{!selectedList}" >
                    
 <apex:column value="{!wrapRec.Name}" />
              
               <apex:column ><apex:outputField value="{!wrapRec.T_Price__c}" />
               <apex:variable var="total1" value="{! total1 + wrapRec.T_Price__c}" />

        <!-- Footer of the first Cell -->>
        <apex:facet name="footer">
            Total:{!total1}  <span class="t1"></span>
        </apex:facet>
               </apex:column>
 </apex:pageBlockTable> 
             
              </apex:pageBlock>

   <script>
   document.getElementsByClassName('t1')[0].innerHTML = '{!total1}';
   </script>

 
Hi,
Please help me with the below scenario, I have Visualforce page through which I can select different checkbox value  and display the selected item on another visualforce  page without storing it in the object. My Requirment is when the multiple checkboxes are selected and Save botton is clicked, then the checked values need to be display on another page.
Selected Checkbox values should be store in Cookie.

Please help me on this scenario. ThankYou.
Below is my Visualforce Page.
<apex:page controller="TourHomeContrllr1" standardStylesheets="false" showHeader="false">
<apex:repeat value="{!naamClicked}" var="t">
    <div class="row">
    <div class="col-md-12 maincol" data-toggle="modal" data-target="#myModal" id="id1" >
                       
                     <div style="float:right;margin-top:5px;" class="img-responsive">
		<apex:outputField value="{!t.Tour_Place_Images__c}" style="width:200px;height:200px;" > </apex:outputField></div>
<br></br>                 
                <apex:form >    
                        <div style="float:right;"><apex:inputField value="{!t.Select__c}"></apex:inputField>
                        </div><br></br>   
                </apex:form>           
      </div> 
     </div>
     </apex:repeat>
 <apex:pageBlock >
                  <apex:form >
                  <apex:pageBlockSection >
                     <apex:commandButton action="{!addToCart}" value="Book Place" styleClass="btn btn-primary" rerender="select_places"/> </apex:pageBlockSection>
                         </apex:form>
                </apex:pageBlock>
                
                     <apex:pageBlock title="Your Places" id="select_places">
 <apex:outputText value="{!cartContents}" escape="true"/> </apex:pageBlock>
</apex:page>

 
Hi everyone,
I need help to write a test class for my code, actually i'm new to this if anyone know please help me. Below is my code
public class TestController {
public Map<String, String> prodCounts{get; set;}
public List<String> prods{get; set;}

public String poNo;
public String getpoNo(){return poNo; }
public void setpoNo(String po) {
    poNo = po;
   TestController();
}
 
    public void TestController() {
              
        prodCounts=new Map<String, String>();
        prods=new List<String>();
        for(AggregateResult ag:[select Product2__c prod, count(Id) cnt from test_transaction__c where Po_num__c=:poNo group by Product2__c]){
            prodCounts.put(String.ValueOf(ag.get('prod')),String.ValueOf(ag.get('cnt')));
            prods.add(String.ValueOf(ag.get('prod')));         
        }
        
    }        
}

page is:

<apex:page controller="TourHomeContrllr1" standardStylesheets="false" showHeader="false">
<apex:repeat value="{!naamClicked}" var="t">
    <div class="row">
    <div class="col-md-12 maincol" data-toggle="modal" data-target="#myModal" id="id1" >
                       
                     <div style="float:right;margin-top:5px;" class="img-responsive">
		<apex:outputField value="{!t.Tour_Place_Images__c}" style="width:200px;height:200px;" > </apex:outputField></div>
<br></br>                 
                <apex:form >    
                        <div style="float:right;"><apex:inputField value="{!t.Select__c}"></apex:inputField>
                        </div><br></br>   
                </apex:form>           
      </div> 
     </div>
     </apex:repeat>
 <apex:pageBlock >
                  <apex:form >
                  <apex:pageBlockSection >
                     <apex:commandButton action="{!addToCart}" value="Book Place" styleClass="btn btn-primary" rerender="select_places"/> </apex:pageBlockSection>
                         </apex:form>
                </apex:pageBlock>
                
                     <apex:pageBlock title="Your Places" id="select_places">
 <apex:outputText value="{!cartContents}" escape="true"/> </apex:pageBlock>
</apex:page>



controller is:

public class TourHomeContrllr1 {
  public List<Tour_Places__c> tourInformation{ get; set;}
public List<Tour_Places__c> getNaamClicked() {
        tourInformation=[Select Name,Place__c,Tour_Place_Images__c,Select__c,Tour_Name__c,Tour_Price__c from Tour_Places__c where Tour_Name__c in :[Select Name from Tours__c where Id =:ApexPages.currentPage().getParameters().get('oid')] ];
    return tourInformation;
    }   
  public List<Tour_Places__c> bookInformation{ get; set;}
public List<Tour_Places__c> getSelectClicked() {
        bookInformation=[Select Name,Place__c,Tour_Place_Images__c,Select__c,Tour_Name__c,Tour_Price__c from Tour_Places__c where Tour_Name__c in :[Select Name from Tours__c where Id =:ApexPages.currentPage().getParameters().get('oid')] ];
    return bookInformation;
    }
public list<Tour_Places__c> tsel=new list<Tour_Places__c>();
    Map< String,Boolean> select_places = new Map<String,Boolean>(); 
public PageReference addToCart() {
    PageReference pageRef = new PageReference('/apex/cart');
    for(Tour_Places__c p :tourInformation ) {
        if(p.Select__c=TRUE){ 
            select_places.put(p.Place__c, p.Select__c);
            cookieJar c = new cookieJar(p.Place__c, p.Name, String.valueOf(p.Select__c)); 
           }
    }   
    pageRef.setRedirect(true);
    // return pageRef;
    return null;
}
public String getCartContents() {
 if(0 == select_places.size()) {
        return '(cart is empty)';
    }
    String msg = '<ul>\n';
    for(String id : select_places.keyset()) {
    msg += '<li>';
        msg +=  id + ' (' + select_places.get(id) + ')';
        msg += '</li>\n';
    }
    msg += '</ul>';
     Cookie theCookie;
    theCookie = ApexPages.currentPage().getCookies().get('Place__c');
    if(theCookie != null)  
    msg +=theCookie.getValue();
    theCookie = ApexPages.currentPage().getCookies().get('Name');
    if(theCookie != null)  
    msg +=theCookie.getValue();

    theCookie = ApexPages.currentPage().getCookies().get('Select__c');
    if(theCookie != null)  
    msg += theCookie.getValue();
    return msg;
}
public class cookieJar {
        public cookieJar(String place, String Name, String tselect) {
            Cookie pplace = new Cookie('place', place,null,315569260,false);
            Cookie pName = new Cookie('Name', Name,null,315569260,false);
            Cookie qselect = new Cookie('tselect', tselect,null,315569260,false);
            //Set the page cookies using the setCookies() method
            ApexPages.currentPage().setCookies(new Cookie[]
            {pplace, pName, qselect} );
        }
    }//end cookieJar inner class
}


please let me know how to store the selected items only in the cookie...and send the values to the another page.
Hiii Plz Help!!!!!!!!!


I want user to select some items using checkbox field of the object on 1st visualforce page.Then i want it to show the selected items on another visualforce page. Please replyyy.

Hi,

 

I need an urgent help.

I have a input field on my visualforce page which is wrapped in an action function. The field is a checkbox. Once the user clicks on the checkbox i have method in my controller. The issue that i am facing is, the checkbox value is always false in my controller.

Can anyone please help me out and let me know why this is happening.

 

Thanks in advance!

 

Hi,

 

Please help me with the below scenario, I have Visualforce page through which I can select a value from Picklist and based on the Picklist value particular Checkboxes will be displayed on the page. My Requirment is when a checkbox value is selected and Save botton is clicked, then the checkbox value need to be stored in a TextArea Field in the respective Object.

 

Selected Checkbox values should be displayed in a TextArea Field ' PlacesVisisted__c ' in the Contact Object.

 

Please help me on this scenario. ThankYou.

 

Below is my Visualforce Page.

 

<apex:page standardController="Contact">
<apex:form >
<apex:pageBlock title="Update Contact Details">
 <apex:pageBlockButtons location="bottom">
  <apex:commandButton action="{!save}" value="Save"/>
  <apex:commandButton action="{!cancel}" value="Cancel"/>
 </apex:pageBlockButtons>
<apex:pageBlockSection id="NewPage" title="Select The Country">
    <apex:inputField value="{!Contact.Country__c}">
    <apex:actionSupport event="onchange" reRender="IndiaBlock, USBlock, ChinaBlock, AusesBlock"/>
    </apex:inputField>
    <apex:inputText value="{!Contact.Name}"/>
</apex:pageBlockSection> 
<apex:outputPanel id="IndiaBlock">
 <apex:pageBlockSection rendered="{!Contact.Country__c == 'India'}" id="SampleSendInfoBlock" title="Select Places Visited">
    <apex:inputCheckbox label="Agra"/>
    <apex:inputcheckbox label="Delhi"/>
 </apex:pageBlockSection>
</apex:outputPanel>
<apex:outputPanel id="USBlock">
 <apex:pageBlockSection title="Select Places Visited" rendered="{!Contact.Country__c == 'America'}" id="USPageBlock">
  <apex:inputCheckbox label="Newyork"/>
  <apex:inputCheckbox label="Washington"/>
 </apex:pageBlockSection> 
</apex:outputPanel>
<apex:outputPanel id="ChinaBlock">
 <apex:pageBlockSection title="Select Places Visited" rendered="{!Contact.Country__c == 'China'}" id="ChinaPageBlock">
 <apex:inputCheckbox label="Bejing"/>
 <apex:inputCheckbox label="Taiwan"/>
 </apex:pageBlockSection>
</apex:outputPanel>
<apex:outputPanel id="AusesBlock">
 <apex:pageBlockSection title="Select Places Visited" rendered="{!Contact.Country__c == 'Australia'}" id="AusesPageBlock">
 <apex:inputCheckbox label="Sydney"/>
 <apex:inputCheckbox label="Canberra"/>
 </apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>