• Glenn Dailey 1
  • NEWBIE
  • 25 Points
  • Member since 2015
  • Software Developer II
  • Matthews International


  • Chatter
    Feed
  • 0
    Best Answers
  • 5
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 8
    Replies
The 'AccountProcessor' class did not achieve 100% code coverage via your test methods. Make sure that you chose 'Run All' tests in the Developer Console at least once before attempting to verify this challenge. I did the run all with no luck. I did notice that this is the new section that was just added and I ran into issues in the first unit too.

Create an Apex class with a method using the @future annotation that accepts a List of Account IDs and updates a custom field on the Account object with the number of contacts associated to the Account. Write unit tests that achieve 100% code coverage for the class.
Create a field on the Account object called 'Number_of_Contacts__c' of type Number. This field will hold the total number of Contacts for the Account.
Create an Apex class called 'AccountProcessor' that contains a 'countContacts' method that accepts a List of Account IDs. This method must use the @future annotation.
For each Account ID passed to the method, count the number of Contact records associated to it and update the 'Number_of_Contacts__c' field with this value.
Create an Apex test class called 'AccountProcessorTest'.
The unit tests must cover all lines of code included in the AccountProcessor 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.

public class AccountProcessor
{
  @future
  public static void countContacts(Set<id> setId)
  {
      List<Account> lstAccount = [select id,Number_of_Contacts__c , (select id from contacts ) from account where id in :setId ];
      for( Account acc : lstAccount )
      {
          List<Contact> lstCont = acc.contacts ;
         
          acc.Number_of_Contacts__c = lstCont.size();
      }
      update lstAccount;
  }
}

and
@IsTest
public class AccountProcessorTest {
    public static testmethod void TestAccountProcessorTest(){
        Account a = new Account();
        a.Name = 'Test Account';
        Insert a;

        Contact cont = New Contact();
        cont.FirstName ='Bob';
        cont.LastName ='Masters';
        cont.AccountId = a.Id;
        Insert cont;
       
        set<Id> setAccId = new Set<ID>();
        setAccId.add(a.id);
 
        Test.startTest();
            AccountProcessor.countContacts(setAccId);
        Test.stopTest();
       
        Account ACC = [select Number_of_Contacts__c from Account where id = :a.id LIMIT 1];
        System.assertEquals ( Integer.valueOf(ACC.Number_of_Contacts__c) ,1);
  }
 
}
Create an Apex class with a method using the @future annotation that accepts a List of Account IDs and updates a custom field on the Account object with the number of contacts associated to the Account. Write unit tests that achieve 100% code coverage for the class.
Create a field on the Account object called 'Number_of_Contacts__c' of type Number. This field will hold the total number of Contacts for the Account.
Create an Apex class called 'AccountProcessor' that contains a 'countContacts' method that accepts a List of Account IDs. This method must use the @future annotation.
For each Account ID passed to the method, count the number of Contact records associated to it and update the 'Number_of_Contacts__c' field with this value.
Create an Apex test class called 'AccountProcessorTest'.
The unit tests must cover all lines of code included in the AccountProcessor 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.

Illegal assignment from Integer to String when trying to save

code that I'm trying to use line 11 is the issue

public class AccountProcessor
{
  @future
  public static void countContacts(Set<id> setId)
  {
      List<Account> lstAccount = [select id,Number_of_Contacts__c , (select id from contacts ) from account where id in :setId ];
      for( Account acc : lstAccount )
      {
          List<Contact> lstCont = acc.contacts ;
         
          acc.Number_of_Contacts__c = lstCont.size(); // line 11
      }
      update lstAccount;
  }
}

 
Integrating External Data Unit | Salesforce Trailhead
Challenge Not yet complete... here's what's wrong:
The User standard object does not have a custom field with the API name 'Phone_UUID__c'

Integrating External Data Unit | Salesforce Trailhead
The mobile phones being tracked by an external application are used by specific users in your Salesforce instance. Create an indirect lookup relationship between the 'Phone' External Object and the 'User' standard object.
Create an OData 2.0 external data source with 'Mobile Devices' as the label, 'Mobile_Devices' as the name, and this URL: https://phone-odata-demo.herokuapp.com/devices.svc/. Note: If you have completed the previous challenge in this module ('Setting up Lightning Connect'), the External Data Source should already exist in your Developer Edition.
Add a new 'Phone UUID' custom field on the User standard object with the resulting API name of 'Phone_UUID__c'. The field should be of type 'Text' and marked as 'Unique' and 'External ID'.
Change the 'UUID' field on the 'Phone__x' external object to be an indirect lookup relationship to the 'User' standard object. Use the 'Phone_UUID__c' field as the matching key for this indirect lookup relationship. (when I do this the Phone_UUID__c' is missing and it is looking at the account(s) )
Update any existing User record in your Developer Edition instance to have a value of '0000123442' for the 'Phone_UUID__c' field.

I have the API name 'Phone_UUID__c' but it will not complete the challenge 
The 'AccountProcessor' class did not achieve 100% code coverage via your test methods. Make sure that you chose 'Run All' tests in the Developer Console at least once before attempting to verify this challenge. I did the run all with no luck. I did notice that this is the new section that was just added and I ran into issues in the first unit too.

Create an Apex class with a method using the @future annotation that accepts a List of Account IDs and updates a custom field on the Account object with the number of contacts associated to the Account. Write unit tests that achieve 100% code coverage for the class.
Create a field on the Account object called 'Number_of_Contacts__c' of type Number. This field will hold the total number of Contacts for the Account.
Create an Apex class called 'AccountProcessor' that contains a 'countContacts' method that accepts a List of Account IDs. This method must use the @future annotation.
For each Account ID passed to the method, count the number of Contact records associated to it and update the 'Number_of_Contacts__c' field with this value.
Create an Apex test class called 'AccountProcessorTest'.
The unit tests must cover all lines of code included in the AccountProcessor 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.

public class AccountProcessor
{
  @future
  public static void countContacts(Set<id> setId)
  {
      List<Account> lstAccount = [select id,Number_of_Contacts__c , (select id from contacts ) from account where id in :setId ];
      for( Account acc : lstAccount )
      {
          List<Contact> lstCont = acc.contacts ;
         
          acc.Number_of_Contacts__c = lstCont.size();
      }
      update lstAccount;
  }
}

and
@IsTest
public class AccountProcessorTest {
    public static testmethod void TestAccountProcessorTest(){
        Account a = new Account();
        a.Name = 'Test Account';
        Insert a;

        Contact cont = New Contact();
        cont.FirstName ='Bob';
        cont.LastName ='Masters';
        cont.AccountId = a.Id;
        Insert cont;
       
        set<Id> setAccId = new Set<ID>();
        setAccId.add(a.id);
 
        Test.startTest();
            AccountProcessor.countContacts(setAccId);
        Test.stopTest();
       
        Account ACC = [select Number_of_Contacts__c from Account where id = :a.id LIMIT 1];
        System.assertEquals ( Integer.valueOf(ACC.Number_of_Contacts__c) ,1);
  }
 
}
The 'AccountProcessor' class did not achieve 100% code coverage via your test methods. Make sure that you chose 'Run All' tests in the Developer Console at least once before attempting to verify this challenge. I did the run all with no luck. I did notice that this is the new section that was just added and I ran into issues in the first unit too.

Create an Apex class with a method using the @future annotation that accepts a List of Account IDs and updates a custom field on the Account object with the number of contacts associated to the Account. Write unit tests that achieve 100% code coverage for the class.
Create a field on the Account object called 'Number_of_Contacts__c' of type Number. This field will hold the total number of Contacts for the Account.
Create an Apex class called 'AccountProcessor' that contains a 'countContacts' method that accepts a List of Account IDs. This method must use the @future annotation.
For each Account ID passed to the method, count the number of Contact records associated to it and update the 'Number_of_Contacts__c' field with this value.
Create an Apex test class called 'AccountProcessorTest'.
The unit tests must cover all lines of code included in the AccountProcessor 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.

public class AccountProcessor
{
  @future
  public static void countContacts(Set<id> setId)
  {
      List<Account> lstAccount = [select id,Number_of_Contacts__c , (select id from contacts ) from account where id in :setId ];
      for( Account acc : lstAccount )
      {
          List<Contact> lstCont = acc.contacts ;
         
          acc.Number_of_Contacts__c = lstCont.size();
      }
      update lstAccount;
  }
}

and
@IsTest
public class AccountProcessorTest {
    public static testmethod void TestAccountProcessorTest(){
        Account a = new Account();
        a.Name = 'Test Account';
        Insert a;

        Contact cont = New Contact();
        cont.FirstName ='Bob';
        cont.LastName ='Masters';
        cont.AccountId = a.Id;
        Insert cont;
       
        set<Id> setAccId = new Set<ID>();
        setAccId.add(a.id);
 
        Test.startTest();
            AccountProcessor.countContacts(setAccId);
        Test.stopTest();
       
        Account ACC = [select Number_of_Contacts__c from Account where id = :a.id LIMIT 1];
        System.assertEquals ( Integer.valueOf(ACC.Number_of_Contacts__c) ,1);
  }
 
}
Create an Apex class with a method using the @future annotation that accepts a List of Account IDs and updates a custom field on the Account object with the number of contacts associated to the Account. Write unit tests that achieve 100% code coverage for the class.
Create a field on the Account object called 'Number_of_Contacts__c' of type Number. This field will hold the total number of Contacts for the Account.
Create an Apex class called 'AccountProcessor' that contains a 'countContacts' method that accepts a List of Account IDs. This method must use the @future annotation.
For each Account ID passed to the method, count the number of Contact records associated to it and update the 'Number_of_Contacts__c' field with this value.
Create an Apex test class called 'AccountProcessorTest'.
The unit tests must cover all lines of code included in the AccountProcessor 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.

Illegal assignment from Integer to String when trying to save

code that I'm trying to use line 11 is the issue

public class AccountProcessor
{
  @future
  public static void countContacts(Set<id> setId)
  {
      List<Account> lstAccount = [select id,Number_of_Contacts__c , (select id from contacts ) from account where id in :setId ];
      for( Account acc : lstAccount )
      {
          List<Contact> lstCont = acc.contacts ;
         
          acc.Number_of_Contacts__c = lstCont.size(); // line 11
      }
      update lstAccount;
  }
}

 
When I attempt to validate the challenge, I get this error:
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.ListException: List index out of bounds: 0

I went and looked at the External Data Source data and see this:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><feed xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xml:base="http://phone-odata-demo.herokuapp.com/devices.svc/phones" xmlns="http://www.w3.org/2005/Atom"><id>http://phone-odata-demo.herokuapp.com/devices.svc/phones</id><title type="text">phones</title><updated>2016-02-27T04:59:09.327Z</updated><link href="phones" rel="self" title="phones"></link><entry><id>http://phone-odata-demo.herokuapp.com/devices.svc/phones('NTZkMGRjOGI1Nzc4YmYwMzAwMmMxYTk4')</id><category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="devices.phones"></category><link href="phones('NTZkMGRjOGI1Nzc4YmYwMzAwMmMxYTk4')" rel="edit" title="phones"></link><title></title><updated>2016-02-27T04:59:09.328Z</updated><author><name></name></author><content type="application/xml"><m:properties><d:UUID>NTZkMGRjOGI1Nzc4YmYwMzAwMmMxYTk4</d:UUID><d:Brand>HTC</d:Brand><d:PhoneNumber>555-255-5556</d:PhoneNumber></m:properties></content></entry></feed>

The debug log in Salesforce says that the data should have a UUID of '0000123442' but it is 'NTZkMGRjOGI1Nzc4YmYwMzAwMmMxYTk4' in the OData feed.

The actual SOQL query that gets ran for the validation is: 
SELECT ID, UUID__r.Name FROM Phone__x WHERE UUID__c = '0000123442' LIMIT 1

Without that data feed returning 0000123442, there is no way to pass the challenge.

Any thoughts on what I could be doing wrong to not see the correct UUID returned?
Integrating External Data Unit | Salesforce Trailhead
Challenge Not yet complete... here's what's wrong:
The User standard object does not have a custom field with the API name 'Phone_UUID__c'

Integrating External Data Unit | Salesforce Trailhead
The mobile phones being tracked by an external application are used by specific users in your Salesforce instance. Create an indirect lookup relationship between the 'Phone' External Object and the 'User' standard object.
Create an OData 2.0 external data source with 'Mobile Devices' as the label, 'Mobile_Devices' as the name, and this URL: https://phone-odata-demo.herokuapp.com/devices.svc/. Note: If you have completed the previous challenge in this module ('Setting up Lightning Connect'), the External Data Source should already exist in your Developer Edition.
Add a new 'Phone UUID' custom field on the User standard object with the resulting API name of 'Phone_UUID__c'. The field should be of type 'Text' and marked as 'Unique' and 'External ID'.
Change the 'UUID' field on the 'Phone__x' external object to be an indirect lookup relationship to the 'User' standard object. Use the 'Phone_UUID__c' field as the matching key for this indirect lookup relationship. (when I do this the Phone_UUID__c' is missing and it is looking at the account(s) )
Update any existing User record in your Developer Edition instance to have a value of '0000123442' for the 'Phone_UUID__c' field.

I have the API name 'Phone_UUID__c' but it will not complete the challenge