• Chris Marzella
  • NEWBIE
  • 95 Points
  • Member since 2014
  • Salesforce Operational Support Specialist
  • Connect America

  • Chatter
    Feed
  • 1
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 24
    Replies
I get the following error when I've completed the challenge and checked it ....  it looks as though Trial__c has been created as the API Name yet this it doens't appear to recognise it with TrialHead ...  is it me or a bug.

"Challenge not yet complete... here's what's wrong: 
An object with the API name Trail__c does not exist"

Shane
+44 7771762004
 
I want to have a custom object display address like the standard functionality on leads, contacts and accounts when you click on the address field. It should also produce the google map. Any way to do this?
User-added image
What is the simplist way to take user input and do a search on specific fields based on their input?

Ex: they have fields like name and age available//they input John and 23//search returns all John's with an age of 23.

It doesn't need to be anything fancy. The simpler the better.
What is wrong with my SOQL query? This is the error I get: Didn't understand relationship 'Asset' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
 
trigger MatchProductTrigger on Opportunity (before update) {
    
    for(Opportunity opp : Trigger.new){
        List<Product2> currentProduct = [SELECT Id FROM Product2 WHERE Product2.Asset.Account.Id = :opp.Account.Id];
     }
}

 
I am trying to create a new contact upon creation of a new account, which works, but it is not relating to the new account, It relates to another account in my dev org. Why is this? I am sure this is something simple enough. I am new to apex and testing out some basic code.
 
trigger CreateContact on Account (after insert) {
    
    for(Account acc : Trigger.new){
        Contact c = new Contact();
        c.FirstName = 'John';
        c.LastName = 'Lock';
        c.AccountId = acc.Id;
        
        insert c;
    }

}

 
trigger CreateCase on Account (after insert) {
    for(Account hw : Trigger.new){
        
        List<Contact> contact = [SELECT Id FROM Contact LIMIT 1];
        
        Case c = new Case();
        c.AccountId = hw.Id;
        c.ContactId = contact[0];
        c.Status = 'New';
        c.Origin = 'Web';
        
        insert c;
    }
}
What do I need to get to assign the result of this query to a variable?
 
trigger SetTotalCreatures on Deck__c (after update) {

    Integer cardTotal = [SELECT Sum(Number_In_Deck__c) FROM Cards_in_Deck__c WHERE Type__c = 'Creature'];
    
    Deck__c.Total_Creatures__c = cardTotal;
}

 
I'm not sure where I am going wrong. Any help would be appreciated.

Here is my code:
public class StringArrayTest {
    public static String[]generateStringArray(){
        List<String> Test = new List<String>{'Test 0', 'Test 1', 'Test 2'};
            
            for(Integer n=0; n<Test.size(); n++){
                System.debug('Test' + n);
            }
        return Test;
    }
}
This is the error:
Challenge not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.
 
@IsTest
public class TestNewUser{
    static TestNewUserMethod void insertLead(){
    
    Lead l = new Lead();
    
    l.FirstName = 'Apex';
    l.LastName = 'Trigger';
    l.Company = 'Admins Who Code';
    l.LeadStatus = 'Open - Not Contacted';
    
    insert l;
    }

}
[Error] Error: Compile Error: unexpected token: 'insertLead' at line 3 column 34
I am looking for a way to get a contact image into the detail page, but I need something that can scale to thousands of contacts. The below formual works for a small amount of records, but this will quickly become unmanageable. Would Apex be the best route and how would I accomplish this?
 
IMAGE(
    CASE(
        Name,

        'Jeff May',       '/servlet/servlet.ImageServer?id=01590000000rZ17',
        'Steve Molis',    '/servlet/servlet.ImageServer?id=01590000000rZ18',
        'Geoffrey Flynn', '/servlet/servlet.ImageServer?id=01590000000rZ19',

        '/img/s.gif'
    ),
    'Contact Logo'
)

 
I have this lookup field created, but I cannot save due to the name field being required. How can I work around this? Looks like it may need a apex trigger using before update possibly?
I have 2 custom objects. The first object has a large database of items (let's call this object cards for simplicity). The second object is where I want to group different combinations of "cards" into a "hand". I want to add a button in "cards" where I could go down the list view and for example select 2,5,10,Jack,Queen then click the button to add these to my "hand".

How can I do this as simplistic as possible?

Thanks in advance!
I want to have a custom object display address like the standard functionality on leads, contacts and accounts when you click on the address field. It should also produce the google map. Any way to do this?
User-added image
I'm not sure where I am going wrong. Any help would be appreciated.

Here is my code:
public class StringArrayTest {
    public static String[]generateStringArray(){
        List<String> Test = new List<String>{'Test 0', 'Test 1', 'Test 2'};
            
            for(Integer n=0; n<Test.size(); n++){
                System.debug('Test' + n);
            }
        return Test;
    }
}
This is the error:
Challenge not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.
 
What is wrong with my SOQL query? This is the error I get: Didn't understand relationship 'Asset' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
 
trigger MatchProductTrigger on Opportunity (before update) {
    
    for(Opportunity opp : Trigger.new){
        List<Product2> currentProduct = [SELECT Id FROM Product2 WHERE Product2.Asset.Account.Id = :opp.Account.Id];
     }
}

 
I am trying to create a new contact upon creation of a new account, which works, but it is not relating to the new account, It relates to another account in my dev org. Why is this? I am sure this is something simple enough. I am new to apex and testing out some basic code.
 
trigger CreateContact on Account (after insert) {
    
    for(Account acc : Trigger.new){
        Contact c = new Contact();
        c.FirstName = 'John';
        c.LastName = 'Lock';
        c.AccountId = acc.Id;
        
        insert c;
    }

}

 
trigger CreateCase on Account (after insert) {
    for(Account hw : Trigger.new){
        
        List<Contact> contact = [SELECT Id FROM Contact LIMIT 1];
        
        Case c = new Case();
        c.AccountId = hw.Id;
        c.ContactId = contact[0];
        c.Status = 'New';
        c.Origin = 'Web';
        
        insert c;
    }
}
What do I need to get to assign the result of this query to a variable?
 
trigger SetTotalCreatures on Deck__c (after update) {

    Integer cardTotal = [SELECT Sum(Number_In_Deck__c) FROM Cards_in_Deck__c WHERE Type__c = 'Creature'];
    
    Deck__c.Total_Creatures__c = cardTotal;
}

 
I'm not sure where I am going wrong. Any help would be appreciated.

Here is my code:
public class StringArrayTest {
    public static String[]generateStringArray(){
        List<String> Test = new List<String>{'Test 0', 'Test 1', 'Test 2'};
            
            for(Integer n=0; n<Test.size(); n++){
                System.debug('Test' + n);
            }
        return Test;
    }
}
This is the error:
Challenge not yet complete... here's what's wrong: 
Executing the 'generateStringArray' method failed. Either the method does not exist, is not static, or does not return the proper number of strings.
 
@IsTest
public class TestNewUser{
    static TestNewUserMethod void insertLead(){
    
    Lead l = new Lead();
    
    l.FirstName = 'Apex';
    l.LastName = 'Trigger';
    l.Company = 'Admins Who Code';
    l.LeadStatus = 'Open - Not Contacted';
    
    insert l;
    }

}
[Error] Error: Compile Error: unexpected token: 'insertLead' at line 3 column 34
I am looking for a way to get a contact image into the detail page, but I need something that can scale to thousands of contacts. The below formual works for a small amount of records, but this will quickly become unmanageable. Would Apex be the best route and how would I accomplish this?
 
IMAGE(
    CASE(
        Name,

        'Jeff May',       '/servlet/servlet.ImageServer?id=01590000000rZ17',
        'Steve Molis',    '/servlet/servlet.ImageServer?id=01590000000rZ18',
        'Geoffrey Flynn', '/servlet/servlet.ImageServer?id=01590000000rZ19',

        '/img/s.gif'
    ),
    'Contact Logo'
)

 
I want to make a field use the picklist values only.  It has a button on the right that shows the picklist values, but the user can enter anything.
Hello smart people!

I am a real beginner at saleforce and just cannot seem to get a google map to appear on my custom object.  I cannot for the life of me figure out what I have done wrong.  Do I need a zip code field?

Here is what I have:

<apex:page standardController="Event_Manager__c">

<head>

<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 = "{!Event_Manager__c.Street_Address__c}, " + "{!Event_Manager__c.City__c}";

  var infowindow = new google.maps.InfoWindow({
    content: "<b>{!Event_Manager__c.Name}</b><br>{!Event_Manager__c.Street_Address__c}<br>{!Event_Manager__c.City__c}<br>"
  });

  geocoder.geocode( { address: address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK && results.length) {
      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: "{!Event_Manager__c}"
        });

        //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! {!Event_Manager__c.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";
      }
    }
  }

});
</script>

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

</head>

<body>
<div id="map"></div>
</body>
</apex:page>


Thank you in advance anyone who takes the time to look at this