• gneve
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
I have a custom child object with a master-detail relationship to the Opportunity standard object. I have visualforce component to display a map with a pin for each child record related to the opportunity. The below code will display all of the addresses, but only the first time I load the opportunity record. If I refresh the page, the map only displays one of the addresses. 

Any help is appreciated. 
<apex:page standardController="Opportunity">

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

   function initialize()
   {
        var myCenter = new google.maps.LatLng(37.0902, -95.7129);
        var myOptions = { center: myCenter, zoom: 4, mapTypeId: google.maps.MapTypeId.ROADMAP };

        var map = new google.maps.Map(document.getElementById("googleMap"), myOptions);
        var geocoder = new google.maps.Geocoder();

        <apex:repeat var="Prop" value="{!Opportunity.Portfolio_Properties__r}">
          counter++;
          var address = "{!Prop.Property_Street_Address__c}, {!Prop.Property_City__c}, {!Prop.Property_State__c}";
          geocoder.geocode( { 'address': address}, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK && results.length) {
              if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {      
               map.setCenter(results[0].geometry.location); 
                marker = new google.maps.Marker({
                    map: map,
                    position: results[0].geometry.location
                   // title: "{!Prop.Name}"
                });
                marker.setmap(map);
              }      
            } 
          });
        </apex:repeat>
        
         if(counter == 0) {
         // Display map of US if no Candidates found
            alert("There are no properties to map.");
        }
    }
  google.maps.event.addDomListener(window, 'load', initialize );
</script>

<body>
<div id="googleMap" style="width:100%;height:500px;"></div>
</body>
</apex:pageBlock>
</apex:page>

 
  • November 29, 2016
  • Like
  • 0

Hello,

 

I have two triggers that pull information from a completed task, one puts that information on a contact record, one puts that information on a lead record based on the WhoId in the task record. The two triggers are written to be exactly the same. Below is the contact trigger.

 

trigger ContactLastCallResult on Task (after insert,after update)
{
String TSubject='Call';
String TResult='Completed';
String WType='003';
Map<Id, Contact> ContactIDMap = new Map<Id, Contact>();
Set<id> Ids = new Set <id>();
for (Task tk: Trigger.new)
{
Ids.add(tk.WhoId);
}
Map<id, Contact> ContactIDMap2 = new Map<id, Contact>([SELECT Id FROM Contact WHERE Id in :Ids]);
for (Task t: Trigger.new)
if (t.subject.contains(TSubject) && t.status.contains(TResult) && t.WhoType__c.startsWith(WType))
{
Contact c = ContactIDMap2.get(t.WhoId);
c.Last_Call_Result__c = t.CallDisposition;
c.Last_Call_Date__c = t.Completed_Date__c;

ContactIDMap.put(c.id,c);
}
update ContactIDMap.values();
}

 

I put together a simple test class to simulate a task being created:

@isTest
private class WhoType_Test {

static TestMethod void Test0_TestCTaskInsert()
{
Task t = new Task();
t.Subject = 'Call';
t.whoid = '003f0000009ApEU';
t.calldisposition = 'contact';
t.status = 'completed';
t.completed_date__c = t.LastModifiedDate;
insert t;     
}
}

 

When I run the test, I get:

System.NullPointerException: Attempt to de-reference a null object

Trigger.ContactLastCallResult: line 17, column 1

 

Line 17 is:

c.Last_Call_Result__c = t.CallDisposition;

 

Anyone have any ideas?

 

Thanks,


Gus

 

  • September 30, 2013
  • Like
  • 0

I am very new to Apex. I have pulled together about 15 Apex triggers, and I need help building test classes for them. I need to have them ready to deploy very quickly and I do not know enough about Apex yet to really be able to build the test classes. Is there anyone that may be able to help me build test classes for these triggers?

 

Thanks,

 

Gustav

  • September 26, 2013
  • Like
  • 0

I have tried to use two separate mass convert applications from the AppExchange to mass convert leads. I've used ConvertRx Pro from CRM PhD and Mass Convert from Versatile Capitalist. Both of these applications are failing to convert leads for me. The issue appears to be our Box.com integration with Salesforce.

 

Here is the error log on the lead detail from ConvertRx:

 

ConvertLead failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, System.DmlException: Update failed. First exception on row 0 with id 00Qa000001BSG4QEAX; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, box.updateBoxTags: execution of BeforeUpdate

caused by: System.AsyncException: Future method cannot be called from a future or batch method: box.Box_Salesforce_Web_Service.makeFutureHttpRequest(String)

(box): []

(System Code)
: []

 

 

When using Mass Convert, I can generally convert 10 leads at a time, but fail due to too many future calls. An Apex job is created for each conversion that fails, here that error log:

 

Failed First error:

Unauthorized endpoint, please check Setup->Security->Remote site settings. endpoint = https://www.box.com/index.php?rm=box_partner_object_add_tag_to_referenced_folder&partner_id=135&partner_auth_token=%7B%22server_url%22%3A%22https%3A%2F%2... Box_Salesforce_Web_Service makeFutureHttpRequest 707a000000gLwLo

 

 

Has anyone else run into issues with mass conversion of leads failing with similar errors? Any help is much appreciated.

 

Thanks,

 

Gustav

  • September 20, 2013
  • Like
  • 0

Hello,

 

I have two triggers that pull information from a completed task, one puts that information on a contact record, one puts that information on a lead record based on the WhoId in the task record. The two triggers are written to be exactly the same. Below is the contact trigger.

 

trigger ContactLastCallResult on Task (after insert,after update)
{
String TSubject='Call';
String TResult='Completed';
String WType='003';
Map<Id, Contact> ContactIDMap = new Map<Id, Contact>();
Set<id> Ids = new Set <id>();
for (Task tk: Trigger.new)
{
Ids.add(tk.WhoId);
}
Map<id, Contact> ContactIDMap2 = new Map<id, Contact>([SELECT Id FROM Contact WHERE Id in :Ids]);
for (Task t: Trigger.new)
if (t.subject.contains(TSubject) && t.status.contains(TResult) && t.WhoType__c.startsWith(WType))
{
Contact c = ContactIDMap2.get(t.WhoId);
c.Last_Call_Result__c = t.CallDisposition;
c.Last_Call_Date__c = t.Completed_Date__c;

ContactIDMap.put(c.id,c);
}
update ContactIDMap.values();
}

 

I put together a simple test class to simulate a task being created:

@isTest
private class WhoType_Test {

static TestMethod void Test0_TestCTaskInsert()
{
Task t = new Task();
t.Subject = 'Call';
t.whoid = '003f0000009ApEU';
t.calldisposition = 'contact';
t.status = 'completed';
t.completed_date__c = t.LastModifiedDate;
insert t;     
}
}

 

When I run the test, I get:

System.NullPointerException: Attempt to de-reference a null object

Trigger.ContactLastCallResult: line 17, column 1

 

Line 17 is:

c.Last_Call_Result__c = t.CallDisposition;

 

Anyone have any ideas?

 

Thanks,


Gus

 

  • September 30, 2013
  • Like
  • 0

I am very new to Apex. I have pulled together about 15 Apex triggers, and I need help building test classes for them. I need to have them ready to deploy very quickly and I do not know enough about Apex yet to really be able to build the test classes. Is there anyone that may be able to help me build test classes for these triggers?

 

Thanks,

 

Gustav

  • September 26, 2013
  • Like
  • 0