• Thomas Panni
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hi out there,
I an absolute Apex beginner and would like to solve a problem: Once an opportunity is closed won the products from that opportunity should automatically become assets for that customer. I know I need a trigger, a class and a test class. So in general my idea is as follows:

if opp stage = closed won
   and if opp has products
for each product (opp-line item) 
create asset
with account ID...
set asset name = product name

etc...

How can I solve this? Where could I find appropriate code samples? Any help is pretty welcome...
So thanks in advance...

best regards Thomas
Hi guys,
I am quite a newby to apex and vf. I have to following problem to solve:

Using SFDC's standard state and country picklists the user enters an address on accounts. Depending on the selected country selection the belonging country flag should appear in a separate field on the newly created or changed account. I found the SFDC graphics pack on the appexchange and installed it. You can find all flags somewhere under documents. So far fine. If I create a formula using the billing country code field from the account object I get the ID, let's say DE for Germany. If I use the Image function in a formula I can set a hyperlink to a flag using the SFDC unique ID, i.e. something like 906F000000098ZCIAY. The image will show up.
But this requires that you know the ID's of every image and create a real giant formula to get the countries and flags assigned. Instead I wanted to use the file's name, i.e. de.png. From that I wanted to extract the first 2 characters, in this case DE and compare that with the preselected billing country code to automatically get the right flag assigned to the right country. My feeling is that this cannot be solved using a formula. I guess I might need some apex to do it. Can anyone help me out please? Any suggestion would be really appreciated. Thanks so much in advance...

best Thomas

I've done quite a bit of research on the forums on how to include a "simple" Google Map example, and have tried many of them. With all , I seem to end up in the same place as a lot of others end up based on the forum comments - the map never actually comes up. I have a valid API key that I substitute, and still nothing comes up - just a blank VF page. Does anyone have a real working example that I could review and modify?

 

 I just want to display a set of locations on the map. In my case, location is a custom object with country, state,city and zip (not a standard account record). If I can just get something basic working (i.e. actually see a map), I can then modify it to also set the marker colors based on some properties of the location - it's for a dashboard.

 

Any help would be greatly appreciated (something in API V3 would be best, but at least an example that works). I thought this was going to be simple...

Hello all I am still very new to SFDC so bear with me :smileyhappy: . So i have successfully made a visualforce page that will Geocode and capture the lon/lat values of a single account address(thanks to theses boards :) now i wanted to see is if there is a way to run this visualforce page for all accounts in one batch, I do understand that they have to be spaced out to avoid the over limit error I have seen this done before when i used and edited find nearby (thanks to Mr.Reid) but the way i implemented the geocoding is more so through javascript than through apex unlike find nearby.  Also I want to keep my code for Google maps API V3 i'm trying to avoid using V2. Heres my code and thanks in advance:

 

VF Page:

<apex:page standardController="Account" extensions="Monty" id="pg">




<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 
<script type="text/javascript"> 

$(document).ready(function() {
  
  var myOptions = {
    zoom: 15,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControl: false
  }
  
  var map;
  var marker;
  
  var geocoder = new google.maps.Geocoder();
  var address = "{!Account.BillingStreet}, " + "{!Account.BillingCity}, " + "{!Account.BillingPostalCode}, " + "{!Account.BillingCountry}";
  
  var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Account.Name}</b><br>{!Account.BillingStreet}<br>{!Account.BillingCity}, {!Account.BillingPostalCode}<br>{!Account.BillingCountry}"
  });

  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
    //alert( "latitude : " + results[0].geometry.location.lat() );
    //alert( "longitude : " + results[0].geometry.location.lng() );
     var latt =  results[0].geometry.location.lat();
      var lngg =  results[0].geometry.location.lng();
  document.getElementById('alat').value = latt;
   document.getElementById('alon').value = lngg;

      if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
      
        //create map
        map = new google.maps.Map(document.getElementById("map"), myOptions);
      
        //center map
        map.setCenter(results[0].geometry.location);
        
        //create marker
        marker = new google.maps.Marker({
            position: results[0].geometry.location,
            map: map,
            title: "{!Account.Name}"
        });
        
        //add listeners
        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });
        google.maps.event.addListener(infowindow, 'closeclick', function() {
          map.setCenter(marker.getPosition()); 
        });
        
      }
      
    } else {
      $('#map').css({'height' : '15px'});
      $('#map').html("Oops! {!Account.Name}'s billing address could not be found, please make sure the address is correct.");
      resizeIframe();
    }
  });
  
  function resizeIframe() {
    var me = window.name;
    if (me) {
      var iframes = parent.document.getElementsByName(me);
      if (iframes && iframes.length == 1) {
        height = document.body.offsetHeight;
        iframes[0].style.height = height + "px";
      }
    }
  }

});
  function setHidden()
    {
    var Longitude = document.getElementById('pg:form:hlon');
        var hiddenRep = document.getElementById('pg:form:hlat');
        hiddenRep.value = document.getElementById('alat').value;
        Longitude.value = document.getElementById('alon').value;
    }


</script>

<style>
#map {
  font-family: Arial;
  font-size:12px;
  line-height:normal !important;
  height:150px;
  width:300px;
  background:transparent;
}
</style>


 


<div id="map" style="font-size: 24px"><br/>There is a problem with the address verify that the address is correct</div> 

<apex:form id="form">

   <div>
    <label for="alat"><b>Latitude and Longitude: </b></label>
    <input id="alat"/>
    <input id="alon"/>
   </div>
<apex:actionFunction name="kill" action="{!change}"/>
    <apex:inputHidden id="hlat" value="{!alat}"/>
     <apex:inputHidden id="hlon" value="{!alon}"/>      
    
        
    

</apex:form>
<script>
    function save()
    {
kill();

}
    window.onload = setTimeout(setHidden,750)
    window.onload = setTimeout(save,1500)
    

</script>
</apex:page>

 Controller:

 

public  with sharing class Monty {

    public Monty(ApexPages.StandardController controller) {
account2 = [select id,BillingStreet, BillingCity, BillingPostalCode,BillingCountry,Latitude__c,Longitude__c, Name from Account where id = :ApexPages.currentPage().getParameters().get('id')];
    }

 
private  Account account2;


 public Account getAccount() {
            return account2;
      }

 public String alat{get;set;}
 public String alon{get;set;}
 

 
}
   
 public PageReference change(){

account2.Latitude__c = alat;
account2.Longitude__c = alon;
update account2;
PageReference reference=new PageReference('https://na12.salesforce.com/'+ account2.id);
        reference.setRedirect(true);
        return reference;
}



}

 PS I am sure there is some misc code still there that does belong anymore.

Hi,

"Salesforce International Mapping using Google Maps" (https://sites.secure.force.com/appexchange/listingDetail?listingId=a0N300000016d25EAA) is a great, simple app, but it uses version 2 of the gmaps API, which is (a) deprecated, and (b) served over HTTP, which causes SSL errors on modern browsers since SFDC is served over HTTPS.

Is anyone working on updating the app to use the new version of the Google Maps API?

Thanks,

Benj

  • March 13, 2012
  • Like
  • 0