• Newbie999
  • NEWBIE
  • 35 Points
  • Member since 2017
  • beginner

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 10
    Replies
Hi all,

I am getting an error 'The Apex class was found' while solving trailhead- Create Test Data for Apex Tests.
Below is my code:
public class RandomContactFactory {
    
    public static List<contact> generateRandomContacts(integer i, string s){
        List<contact> list1= new list <contact>();
        for(integer t=0; t< i; i++){
            
            contact c= new contact();
            c.FirstName=s+' '+t;
            c.LastName=s;
    
        }
        list1=[select FirstName from contact where LastName=:s];
        return list1;              
    }
    
}

need help here !
Hi,

My maintenance results for salesforce PD-1 are not shown in Webassessor though I have completed the modules. Can anyone guide me on how to correct this??screenshotThanks in Advance :)
Hi,

I need a recommendation of trailheads to be done to learn lightning development as a beginner. As I can see, there are a lot of trails to learn and it's confusing where to start from. So can anyone share the order in which I should solve them (from basics to advanced)

TIA
Hi, Can someone please explain why in some programs they have used Account[] everywhere and somewhere they have created lists and then written SOQL on accounts?

TIA
So am I correct if I say using actionFunction, we can avoid the input required from user like mouseOver, onClick etc which is the case of actionSupport? The actions will be performed automatically during page load etc in case of action function?
<apex:page standardController="Account" recordSetVar="accounts">
    <apex:pageBlock title="Accounts">
        <apex:repeat value="{!Accounts}" var="a">
            <li>
                <apex:outputLink value="/{!a.id}">{!a.Name}</apex:outputLink>
            </li>
        </apex:repeat>
   </apex:pageBlock> 
</apex:page>

BELOW IS THE OUTPUT OF THE ABOVE PROGRAM

output of VF- standard list controller
 
Can I become  a pro in salesforce lightning with good knowledge of salesforce admin part and basics of salesforce development?

Thanks in advance
Any possible technical changes/ settings issue for not getting 100% test coveage for a class in my org.
It's giving 100% coverage in other trailhad playground.

Any suggestions so that i can be more careful the next time
below is my code
@isTest
private class DailyLeadProcessorTest {
    public static string t='0 0 12 7 17 ?';
    static testmethod void testscheduleLead(){
        /*List<Lead> leads = new List<Lead>();
        
        for(Integer i = 0; i < 200; i++){
            Lead lead = new Lead(LastName = 'Test ' + i, LeadSource = '', Company = 'Test Company ' + i, Status = 'Open - Not Contacted');
            leads.add(lead);
        }
        
        insert leads;*/
        list<lead> newleads= new list<lead>();
    for(integer i=0;i<200;i++){
        
       lead l= new lead(LastName='test lastName'+i,company='test company');
        newleads.add(l);
    
    }
        insert newleads;
        test.startTest();
        
         Integer n=[select count() from Lead where LastName like '%test%'];
        system.assertEquals(200,n,'200 new leads not created');
        integer c=[select count() from lead where leadSource='Dreamforce'];
        system.assertEquals(0,c, 'dreamforce leads found');
            //DailyLeadProcessor d= new DailyLeadProcessor();
            string jobId= system.schedule('scheduleleadprocessor',t,new DailyLeadProcessor());
            test.stopTest();
    

    }}
 
global class DailyLeadProcessor implements schedulable {
    global void execute(SchedulableContext ctx){
        list<lead> list1=[select id, name, leadSource from lead where leadSource=null];
        if (!list1.isEmpty()){
        for(lead l: list1){
            l.leadSource='Dreamforce';
            
        }
            update list1;}
            
    }

}
How can i create 25 lead assignment rule quicky? any shortcuts suggested?

Thanks in advance
In the below query: SELECT Id, Name, Industry, AnnualRevenue,     ( SELECT Name, Email, BirthDate FROM Contacts )     FROM Account where name != null limit 5, why writing owner does not return records and we have to write owner.name. While writing name returns records
Hi all,

I am getting an error 'The Apex class was found' while solving trailhead- Create Test Data for Apex Tests.
Below is my code:
public class RandomContactFactory {
    
    public static List<contact> generateRandomContacts(integer i, string s){
        List<contact> list1= new list <contact>();
        for(integer t=0; t< i; i++){
            
            contact c= new contact();
            c.FirstName=s+' '+t;
            c.LastName=s;
    
        }
        list1=[select FirstName from contact where LastName=:s];
        return list1;              
    }
    
}

need help here !
Hi,

I need a recommendation of trailheads to be done to learn lightning development as a beginner. As I can see, there are a lot of trails to learn and it's confusing where to start from. So can anyone share the order in which I should solve them (from basics to advanced)

TIA
below is my code
@isTest
private class DailyLeadProcessorTest {
    public static string t='0 0 12 7 17 ?';
    static testmethod void testscheduleLead(){
        /*List<Lead> leads = new List<Lead>();
        
        for(Integer i = 0; i < 200; i++){
            Lead lead = new Lead(LastName = 'Test ' + i, LeadSource = '', Company = 'Test Company ' + i, Status = 'Open - Not Contacted');
            leads.add(lead);
        }
        
        insert leads;*/
        list<lead> newleads= new list<lead>();
    for(integer i=0;i<200;i++){
        
       lead l= new lead(LastName='test lastName'+i,company='test company');
        newleads.add(l);
    
    }
        insert newleads;
        test.startTest();
        
         Integer n=[select count() from Lead where LastName like '%test%'];
        system.assertEquals(200,n,'200 new leads not created');
        integer c=[select count() from lead where leadSource='Dreamforce'];
        system.assertEquals(0,c, 'dreamforce leads found');
            //DailyLeadProcessor d= new DailyLeadProcessor();
            string jobId= system.schedule('scheduleleadprocessor',t,new DailyLeadProcessor());
            test.stopTest();
    

    }}
 
global class DailyLeadProcessor implements schedulable {
    global void execute(SchedulableContext ctx){
        list<lead> list1=[select id, name, leadSource from lead where leadSource=null];
        if (!list1.isEmpty()){
        for(lead l: list1){
            l.leadSource='Dreamforce';
            
        }
            update list1;}
            
    }

}
I am unable to login to Trailhead !! I am again and again redirected to login.salesforce.com
Anyone came accross to any such issue? 

Tried creating multiple playgrounds !! Still unable to use Trailhead any solution to this?
In the below query: SELECT Id, Name, Industry, AnnualRevenue,     ( SELECT Name, Email, BirthDate FROM Contacts )     FROM Account where name != null limit 5, why writing owner does not return records and we have to write owner.name. While writing name returns records
Hi all, 

I have a problem with this challenge :

Create a Queueable Apex class that inserts the same Contact for each Account for a specific state. Write unit tests that achieve 100% code coverage for the class.
Create an Apex class called 'AddPrimaryContact' that implements the Queueable interface.
Create a constructor for the class that accepts as its first argument a Contact sObject and a second argument as a string for the State abbreviation.
The execute method must query for a maximum of 200 Accounts with the BillingState specified by the State abbreviation passed into the constructor and insert the Contact sObject record associated to each Account. Look at the sObject clone() method.
Create an Apex test class called 'AddPrimaryContactTest'.
In the test class, insert 50 Account records for BillingState "NY" and 50 Account records for BillingState "CA". Create an instance of the AddPrimaryContact class, enqueue the job and assert that a Contact record was inserted for each of the 50 Accounts with the BillingState of "CA".
The unit tests must cover all lines of code included in the AddPrimaryContact class, resulting in 100% code coverage.
Run your test class at least once (via 'Run All' tests the Developer Console) before attempting to verify this challenge.


I haven't 100% for my test class. 
 
@isTest
 public class AddPrimaryContactTest {
   
   
     @isTest static void TestList(){
         List<Account> Teste = new List <Account>();
         for(Integer i=0;i<50;i++){
             
             Teste.add(new Account(BillingState = 'CA', name = 'Test'+i));
         }
             for(Integer j=0;j<50;j++){
             
             Teste.add(new Account(BillingState = 'NY', name = 'Test'+j));
         
         }
         insert Teste;
         Contact co = new Contact();
          String state = 'CA';
     AddPrimaryContact apc = new AddPrimaryContact(co, state);
	Test.startTest();
	System.enqueueJob(apc);
     Test.stopTest();
         for (Account t:Teste){
             if( t.BillingState == 'CA'){
               	  
             	System.assertEquals(1, t.Number_of_contacts__c);
            
             
         }
         }      
}
 }
 
public class AddPrimaryContact implements Queueable{
    private Contact c;
    private String state;
    public  AddPrimaryContact(Contact c, String state){
        this.c = c;
        this.state = state;
        
    }
     public void execute(QueueableContext context) {
        List<Account> ListAccount = [SELECT ID, Name FROM ACCOUNT WHERE BillingState = :state LIMIT 200];
         for (Account l:ListAccount){
             for (Contact co:l.Contacts){
                 
                 c = co.clone(false,false,false,false);
                 insert c;
             }
                 
                 
             }
             
         }

}


Anyone can help me please?
Thanks!
Hi All,

When we are trying to insert the "Price Book Entry" records. Few records got inserted from the CSV file and for few records we are facing the following error:

"This price definition already exists in this price book"

Could you please check and let me know what was the cause of the error. Any modifications do we need to make in CSV file.

Please suggest.

Thanks,
Anil

"Challenge not yet complete... here's what's wrong: 
Account setup for challenge incomplete. Please add 'Prospect', 'Customer' and 'Pending' picklist values to the Account 'Type' field"


Working on the challenge for 
Process Automation: Routing Records with Approvals

Everything is lock-tight except for one detail pictured in screenshot.

I felt like I tried every permutation in the book to fix this (all acounts are synced, all process is in order, I have reset, redefined and created everything that seems feasable) but apparently I am missing this, or it would have worked. Any advice would be greatly appreciated.User-added image

Thank you!