• Beatriz Minguez
  • NEWBIE
  • 40 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 2
    Replies
Dear all, 
I am trying to solve one of the Trailhead Challenges in the unit: Creating Test Data for Apex Tests and is giving me the following error:

Challenge Not yet complete... here's what's wrong: 
Executing the 'generateRandomContacts' method failed. Either the method does not exist, is not static, or did not return the correct set of Contact records.

The following is the code; 
public class RandomContactFactory {

    public static List<Contact> generateRandomContacts (integer nNumContacts, string sLastName)
    {
        List<Contact> lContactList = new List<Contact>();
        
        for(integer i=0; i<nNumcontacts; i++)
        {
            Contact c = new Contact(LastName= sLastName + ' ' +i);
            lContactList.add(c);

        }    
        return lContactList;
    }
    
}

What I need to solve is the following:

 Create an Apex class that returns a list of contacts based on two incoming parameters: one for the number of contacts to generate, and the other for the last name. The list should NOT be inserted into the system, only returned. The first name should be dynamically generated and should be unique for each contact record in the list.The Apex class must be called 'RandomContactFactory' and be in the public scope.
The Apex class should NOT use the @isTest annotation.
The Apex class must have a public static method called 'generateRandomContacts' (without the @testMethod annotation).
The 'generateRandomContacts' method must accept an integer as the first parameter, and a string as the second. The first parameter controls the number of contacts being generated, the second is the last name of the contacts generated.
The 'generateRandomContacts' method should have a return type of List<Contact>.
The 'generateRandomContacts' method must be capable of consistently generating contacts with unique first names.
For example, the 'generateRandomContacts' might return first names based on iterated number (i.e. 'Test 1','Test 2').
The 'generateRandomContacts' method should not insert the contact records into the database.

Can anyone help me? 

Thanks!

Bea

 

How can I call the procedure CheckDates with two dates? VerifyDate.CheckDates('310/01/2015', '30/02/2016') is giving me an error as they are treating the parameters as two strings.. 

public class VerifyDate {
    
    //method to handle potential checks against two dates
    public static Date CheckDates(Date date1, Date date2) {
        //if date2 is within the next 30 days of date1, use date2.  Otherwise use the end of the month
        if(DateWithin30Days(date1,date2)) {
            return date2;
        } else {
            return SetEndOfMonthDate(date1);
        }
    }

Can anyone help me?

Thanks,

Bea
The sSearchWord is giving me a compiling error. Can anyone tell me how to use sSearchWord in the SOSL code as a parameter?
public class ContactAndLeadSearch {

    public static List<List< SObject>> searchContactsAndLeads (string sSearchWord) {

         List<List<sObject>> searchList = [FIND sSearchWord IN ALL FIELDS 
                   RETURNING Contact(FirstName,LastName), Lead(FirstName,LastName)];

Thanks, 

Bea
Regarding using SOQL to assign and retrieve attributes, I need identify the Postal Code of the Contact and I do not know how to name it?

Imagine I am having the following code:

Contact[] cts = [SELECT Contact.LastName, Contact.Postal_Code FROM Contact WHERE LastName =: sName OR PostalCode =: sPostalCode]; 
  
        System.debug('Last Name forund + cts[0].LastName);
        System.debug('PostalCode found' + cts[0].PostalCode);

The problem is that Contact.PostalCode can't be found and I do not know how to name it. 

Anyone can help me?

Thanks!

Bea
 
I am on a Beginners Module in the Trailhead and I am exactly on a section named "Top 10 “You Can’t Miss” Pages in Setup". Item number 6 is "Sandboxes". When searching the term "Sandbox" in the Setup search, I can't find anything related to it. Is there something that I am missing? How can I reach the "Sandbox" properties?
Can anyone tell me when creating an App there is a drop down list asking for the Gender? Can anyone put me an example of use?

Thanks, 

Bea 
Regarding using SOQL to assign and retrieve attributes, I need identify the Postal Code of the Contact and I do not know how to name it?

Imagine I am having the following code:

Contact[] cts = [SELECT Contact.LastName, Contact.Postal_Code FROM Contact WHERE LastName =: sName OR PostalCode =: sPostalCode]; 
  
        System.debug('Last Name forund + cts[0].LastName);
        System.debug('PostalCode found' + cts[0].PostalCode);

The problem is that Contact.PostalCode can't be found and I do not know how to name it. 

Anyone can help me?

Thanks!

Bea
 
Can anyone tell me when creating an App there is a drop down list asking for the Gender? Can anyone put me an example of use?

Thanks, 

Bea