+ Start a Discussion

I am trying to solve the challange of the HTTP and Basic Callout module of Salesforce trailhead and I am having some queries in which you could point to the right direction:

1- The challange asked us to call this URL https://th-apex-http-callout.herokuapp.com/animals/:id in method getAnimalNameById... should that URL be in this form instead of the above https://th-apex-http-callout.herokuapp.com/animals?id ? Where id is a parameter in the URL.

2- When I tried to check the solution of the challange, Salesforce generated that error for me
"Challenge Not yet complete... here's what's wrong: 
Executing the 'getAnimalNameById' method on 'AnimalLocator' failed. Make sure the method exists with the name 'getAnimalNameById', is public and static, accepts an Integer and returns a String."
despite that my class implementation has this method declared as public static String as below in the code snippet:
public class AnimalLocator {
	public static String getAnimalNameById(Integer id) {
		Http http = new Http();
		HttpRequest request = new HttpRequest();
		HttpResponse response = http.send(request);
		List<Object> animals = NULL;
		String returnValue = NULL;
		// if the request was successful, then parse the JSON response
		if (response.getStatusCode() == 200) {
			Map<String, Object> result = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
			animals = (List<Object>) result.get('animals');
		if (animals.size() > 0 && animals != NULL && id < animals.size()) {
			returnValue = (String) animals.get(id);
		return returnValue;
	} // end getAnimalNameById method
} // end AnimalLocator class

I would appreciate your help in this post.

Thank you,

Best Answer chosen by SinanBunni
No, you should be replacing the Id at the end of the url with the id passed into the method

request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/' + id);

Katie KourtakisKatie Kourtakis 
I am seeing this error...'Challange Not yet complete...here's what's wrong: The 'Shift Hours' field on the 'Volunteer Shift' record is not working as expected. I'm stuck as to what I am doing wrong. It's probably a simple fix that I'm over looking. Help solving this problem would be greatly appreciated! Thanks!

User-added image
User-added image
User-added image
Best Answer chosen by Katie Kourtakis
Multiply your formula by 24
Laura KempenaarLaura Kempenaar 
Hi all,

Another question from me: I am still working on the admin module within Trailheads and I cant finish it, because in the Create object specific quick actions-part I can't seem to find Properties under Tabs. I did create Property/Properties as an object, but then I have to do this:

Enter Tab in the Quick Find box, then select Tabs.
In the Custom Object Tabs list, click New.
In the Object dropdown list, select Property.

And in that object dropdown list, there is no Property. Can someone tell me what to do here, please? Thanks! :)
Best Answer chosen by Laura Kempenaar
Andras Arva(HU)Andras Arva(HU)
hey @Laura Kempenaar
I was in the same situation, reviewed tab access, even FLS but did NOT helped.
After a while i noticed that if i scroll UP in my mobile it refresh my tabs list ! (where you generally see tabs/recent/connections etc.)
And this was necessary as probably tab names were cached (if i use another mobile to connect that could work w/o it)
H 007H 007 
Hi, I need to setup a integration from Sitecore to Salesforce. So anyone please help me to send data from Sitecore to Salesforce..
Best Answer chosen by H 007
VinayVinay (Salesforce Developers) 
Check below references for sitecore to salesforce integration.


Also you can check on appexchange if there are any tools that matches your requirement.


Please mark as Best Answer if above information was helpful.

I'm in a terrible dilemma with the trigger. I was wondering why there is no id assigned on the record anymore
trigger trigger_Account on Account(before insert, before update){
  for( Account acc : Trigger.new){
    system.debug('Account id: ' + acc.id);
this change affected some of my previous triggers
Best Answer chosen by jkc

Your trigger will fire in two condition before insert and before update.

In before insert - id value wont be there....since the record is not inserted into database.
in before update - id value will be there and you will be albe to use that id for calcualtion.

Only in After Insert you will get the id of that record.

Let me know if you need more clarification. If it answers your question please mark it as answer.

Manoj S
Rahul  37Rahul 37 


I want to developer a business application like Gmail.

so if i use community site but url showing last www.abc.salesforce.com but i want to create my own custom url like www.abc.com.

So is it possible to create and developer own custom url ?



Best Answer chosen by Rahul 37
VinayVinay (Salesforce Developers) 
Nope, your application will run on salesforce platform unless you are trying to integrate any third party application like AWS etc.

Sumesh ChandranSumesh Chandran 
The below batch class will be processing a little over 2.5 million records. The START method will be sending in the whole 2.5 million records to the execute method and the execute method does the processing on each of the 2.5 million records inside a for loop. 
Also the for loop has a SOQL inside which I believe cannot be avoided to get the right numbers. 
Is this the right way of doing this or are there any other better ways. Please help!

Also when the running the below batch class I get the First Error: Too many query rows error.
global class MDUSquadRawDataBatchTest implements Database.Batchable<sObject>, Database.Stateful {  
    List<Address_Master__c> addressList = new List<Address_Master__c>();
    Set<String> addresses = new Set<String>();
    // Start Method
    global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator('SELECT Street_Address__c,City_Name__c FROM MDU_Squad_Raw_Data__c');
    // Execute method
    global void execute(Database.BatchableContext BC, List<MDU_Squad_Raw_Data__c> rawData) {        
        for(MDU_Squad_Raw_Data__c mduRawData: rawData) {
            List<MDU_Squad_Raw_Data__c> addressData = [SELECT Street_Address__c,City_Name__c,Province_Code__c,Postal_Code__c,Internet_Service__c,Video_Service__c,Phone_Service__c FROM MDU_Squad_Raw_Data__c WHERE Street_Address__c=:mduRawData.Street_Address__c AND City_Name__c=:mduRawData.City_Name__c];
            String fullAddress = addressData[0].Street_Address__c+' '+addressData[0].City_Name__c+' '+addressData[0].Province_Code__c+' '+addressData[0].Postal_Code__c;
            Address_Master__c theAddress = new Address_Master__c();
            if(!addresses.contains(fullAddress.substringBeforeLast(' '))) {
                theAddress.Name = addressData[0].Street_Address__c;
                theAddress.City_Name__c = addressData[0].City_Name__c;
                theAddress.Province_Code__c = addressData[0].Province_Code__c;
                theAddress.Postal_Code__c = addressData[0].Postal_Code__c; 
                fullAddress = addressData[0].Street_Address__c+' '+addressData[0].City_Name__c+' '+addressData[0].Province_Code__c+' '+addressData[0].Postal_Code__c;
                theAddress.Full_Address_Ext_Id__c = fullAddress;

                addresses.add(fullAddress.substringBeforeLast(' '));
        Database.Upsert(addressList, Address_Master__c.Fields.Full_Address_Ext_Id__c, true);
    // Finish Method    
    global void finish(Database.BatchableContext BC) {

I request if someone could please help me with this, as I am dealing with this for some time, with no idea on how to fix this.
Best Answer chosen by Sumesh Chandran
Andrew GAndrew G
if you are still struggling, here is a code example that may point you in the right direction:
//Loop1 - get street and city name data into two lists
list<string> streetList = new List<string>();
list<string> cityList = new List<string>();
for(MDU_Squad_Raw_Data__c mduRawData: rawData) {
//do query:
List<MDU_Squad_Raw_Data__c> addressData = [SELECT Street_Address__c, City_Name__c, Province_Code__c, Postal_Code__c, Internet_Service__c, Video_Service__c, Phone_Service__c 
    FROM MDU_Squad_Raw_Data__c 
    WHERE Street_Address__c IN :streetList 
        AND City_Name__c IN :cityList];

//Loop addressData to make Map with Key street~city
Map<string,MDU_Squad_Raw_Data__c> mapAddressData = new Map......
for(MDU_Squad_Raw_Data__c raw : addressData){
  //psuedo - if no key, then add
  if !(mapAddressData.containsKey(raw.Street_Address__c+'~'+raw.City_Name__c){
      mapAddressData.add(raw.Street_Address__c+'~'+raw.City_Name__c, raw);

//now we loop the original list checking the map for the key and then update as required
list<MDU_Squad_Raw_Data__c > updateList = new....
for(MDU_Squad_Raw_Data__c raw: rawData) {
        MDU_Squad_Raw_Data__c address = mapAddressData.get(raw.Street_Address__c+'~'+raw.City_Name__c);
        //now update the raw record with address record
        raw.postalcode = addres.province code;
     } //endi f
}//end loop
if (updateList.size()>0){
   update udpateList;

John De SantiagoJohn De Santiago 

After a lot of persistence I finally was able to get repeating header and footers when rendering a Visualforce page as a PDF. The key to this is the page2PDF support of CSS3. 


Here is the css I came up with:


<style type="text/css">

@page {

@top-center {

content: element(header);



div.header {

padding: 10px;

position: running(header);




In the visualforce page I have the header setup as a div with the class name "header" the position running command pulls the content in my div and repeats it at the top of every page. The key for some reason is to put your header and footer divs at the top before you put your content on the page.


Here is my page


<apex:page renderAs="pdf">


<style type="text/css" media="print">

@page {

@top-center {

content: element(header);


@bottom-left {

  content: element(footer);




div.header {

padding: 10px;

position: running(header);


div.footer {

display: block;

padding: 5px;

position: running(footer);



.pagenumber:before {

content: counter(page);


.pagecount:before {

content: counter(pages);





<div class="header">

<div>My Header Text</div>



<div class="footer">

<div>Page <span class="pagenumber"/> of <span class="pagecount"/></div>



<div class="content">

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nec nulla turpis. Suspendisse eget risus sit amet lectus ornare varius. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean nec urna purus, adipiscing accumsan massa. Nullam in justo nulla, sed placerat mauris. In ut nunc eget libero posuere luctus. Donec vulputate sollicitudin ultrices. Nulla facilisi. Mauris in sapien arcu. Phasellus sit amet quam non mi ornare tincidunt ac quis lectus.</p>




I cut the content text short for the purpose of this post. I am sure it will just take some more playing around.


Hope this helps someone avoid some late nights like I spent trying to figure this out. :smileyhappy:



Message Edited by JohnDS on 03-10-2010 07:34 PM
Best Answer chosen by Admin (Salesforce Developers) 
John De SantiagoJohn De Santiago

You need to play around with the margin-top setting in the @page tag of the css or add one if you have not already. I usually just put a margin-top: 100px and margin-bottom:80px to keep the content from overlapping the heading. You can use smaller sizes but this allows room for an image.


I have also created a component for adding header and footer tags along with sample code. You can download the component from my blog at http://thurly.net/02s7

Saurav Roy 15Saurav Roy 15 
Hello Everyone,
Can anyone please explain the significance of the Test.startTest() and Test.stopTest() in terms of asynchronous calls/apex ? I am aware of the governer limits being reset. 
Best Answer chosen by Saurav Roy 15
AbhishekAbhishek (Salesforce Developers) 
Hi Saurav,

As you have already know by now that Apex is governed by certain boundaries. The term coined for this is 'Governor Limits'.

There are two additional system static methods provided by Apex. These methods, Test.startTest and Test.stopTest, are used when testing governor limits. Or in other words, executing test scenarios with a larger data set.

These static methods allow a test method to separate the Apex resources and governor limits being used to prepare and initialize the dataset from the resources and limits used during the actual test execution.

Bottom Line - 

Governor limits are reset when the Test.startTest appears and the code between Test.startTest and Test.stopTest executes in a fresh set of governor limits (Context changes). Also, Test.stopTest appears, the context is again moved back to the original code.

Example -

you have 100 lines of code in your test class.

you have start test at 30 
you have stop test at 70

So the line of code from 30 -70 is the indifferent context of governor limits and
line 1-30/71-100 in different contexts. 

Total of 2 contexts here.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Salesforce Support.



I have a package with a publisher name as MyCorp, but I would love to change to something more meaningful (as my real company name), but I can't find a way of doing it.


Is there a way, or do I need to create a new package (or is there any other way)?



Best Answer chosen by Admin (Salesforce Developers) 

Change the your dev organizations name under Company Profile > Company Information in setup.  It will take up to 30 minutes, but this will change the publisher shown for packages in subscriber orgs.