You need to sign in to do that
Don't have an account?
'Using Future Methods' Trailhead Issue
Hello,
When I'm trying to Check Challenge, I receive this king of message : "The 'Number_Of_Contacts__c' field does not exist on the Account object."
I've double/triple checked if this field was present and ... it is.
I don't understand since all the test are goods.
Could you help me with this issue ?
Regards,
When I'm trying to Check Challenge, I receive this king of message : "The 'Number_Of_Contacts__c' field does not exist on the Account object."
I've double/triple checked if this field was present and ... it is.
I don't understand since all the test are goods.
Could you help me with this issue ?
Regards,
==> check the permissions / FLS for that field.
==> Check the API Name
Regards,
Mahesh
All Answers
==> check the permissions / FLS for that field.
==> Check the API Name
Regards,
Mahesh
HI Use this code
Can you tell me why its SELECT Id FROM Contacts? What is Contacts? The table is Contact so why is Cotnacts used here?
Its a Child Relationship and look into the below links:
Relationship Queries:
If Job_Application__c is the child Object and Review__c is the parent object then
List<Job_Application__c> jaList = [Select Id, Name, Review__c, Review__r.Name from Job_Application__c];
If Review__c is the child Object and Job_Application__c is the parent object then
List<Review__c> rList = [Select Id, Name, Job_Application__c, Job_Application__r.Name from Review__c];
Also look into the below links for more information about Relationship Queries:
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_understanding.htm
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships.htm
https://developer.salesforce.com/page/A_Deeper_look_at_SOQL_and_Relationship_Queries_on_Force.com
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships_lookup.htm
https://developer.salesforce.com/blogs/developer-relations/2013/05/basic-soql-relationship-queries.html
Please do let me know if it helps you.
Regards,
Mahesh
If you have namespace created on your org, you'll see this error even if you've setup this field correctly.
In order to resolve this you can setup a trailhead hands on org, as you can not delete the namespace in your org and then associate it with your trailhead account to complete this trailhead module.
Here is how you can check if you've namespace setup on your developer org:
1. Click on setup >> search for packages in quick find >> click on package and you'll see namespace information if set or it'll show none.
2. Create a new developer org >> now from your existing trailhead account >> click on manage my hands on org >> click on connect to an org and verify your new developer org.
3. Once verfied click on check challenge
You shoule be able to complete it.
Thanks
Look for this
![User-added image](/forums/servlet/rtaImage?eid=9070G000000Dqnr&feoid=Body&refid=0EM0G0000009g8Z)
And select the org in which you developed your code.
Sample Class:-
Public class AccountProcessor {
@future
public static void countContacts(List<Id> recordIds) {
List<Account> accounts = [Select Id,Name,(select Id from Contacts) from Account Where Id IN :recordIds];
for(Account a : accounts)
{
a.Number_Of_Contacts__c=a.Contacts.size();
}
update accounts;
}
}
Test Class:-
@isTest
private class AccountProcessorTest {
@IsTest static void countContactsTest() {
Test.startTest();
Account a = new Account(Name='ABCD');
insert a;
List<Id> AcId = new List<Id>();
Contact c = new Contact(LastName='ABCD',AccountId=a.Id);
insert c;
for(Account acc : [select id from Account where id=:a.Id])
{
AcId.add(acc.id);
}
AccountProcessor.countContacts(AcId);
Test.stopTest();
}
}
※“Number_Of_Contacts__c” is wrong