You need to sign in to do that
Don't have an account?
Kevin Collins 9
Issue with Trailhead challenge - Implement a basic Domain class and Apex trigger?
Challenge Not yet complete... here's what's wrong:
The 'Accounts' class 'onApplyDefaults' method does not appear to be setting the Description field to 'Domain classes rock!' correctly for a default value.
Any recommendations or suggestions would be greatly appreciated.
The 'Accounts' class 'onApplyDefaults' method does not appear to be setting the Description field to 'Domain classes rock!' correctly for a default value.
public override void onApplyDefaults() { List<Account> updatedAccounts = new List<Account>(); for (Account acct : (List<Account>)Records) { acct.Description = 'Domain classes rock!'; updatedAccounts.add(acct); } fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork(new Schema.SObjectType[] { Account.SObjectType }); uow.registerDirty(updatedAccounts); uow.commitWork(); }
Any recommendations or suggestions would be greatly appreciated.
I passed this challenge without the code related to the fflib_SObjectUnitOfWork class. So the lines 3, 7, and [10-12] are not needed. I guess this part is done behind the sceen in the fflib_SObjectDomain. Unless there is another problem in the trigger itself or somewhere else, making these changes shoud get you through.
have a good one
I changed my code but for some reason I'm getting the same error.
Challenge Not yet complete... here's what's wrong:
The 'Accounts' class 'onApplyDefaults' method does not appear to be setting the Description field to 'Domain classes rock!' correctly for a default value.
Here is the code I passed the challenge with:
public class Accounts extends fflib_SObjectDomain {
public Accounts(List<Account> sObjectList)
{
super(sObjectList);
}
public class Constructor implements fflib_SObjectDomain.IConstructable {
public fflib_SObjectDomain construct(List<sObject> sObjectList) {
return new Accounts(sObjectList);
}
}
public override void onApplyDefaults()
{
// Apply defaults to account
for(Account acc: (List<Account>) Records)
{
if(acc.Description == null)
{
acc.Description = 'Domain classes rock!';
}
}
}
public override void handleBeforeInsert()
{
onApplyDefaults();
}
public override void onBeforeUpdate(Map<Id,sObject> existingRecords) {
String rock = 'Domain classes rock!';
List<Account> updatedAccounts = new List<Account>();
for(Account acc : (List<Account>) Records) {
acc.AnnualRevenue = rock.getLevenshteinDistance(acc.Description);
updatedAccounts.add(acc);
}
fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork(new Schema.SObjectType[] { Account.SObjectType });
uow.registerDirty(updatedAccounts);
}
}
trigger AccountsTrigger on Account (
after delete, after insert, after update, after undelete, before delete, before insert, before update)
{
//Creates Domain class instance and calls appropriate methods
fflib_SObjectDomain.triggerHandler(Accounts.class);
}
1) https://developer.salesforce.com/forums/?id=9060G000000XgMoQAK
2) https://developer.salesforce.com/forums/?id=9060G000000XgPsQAK
Let us know if this will help you
Project Look Up custom..
then form__c(custom object) has the Account & Project lookup in form__c object..
if account lookup is selected ABC record
then Project lookup should show associted or related records in lookup
this functionality should be in lookup and pick list....
so please send the code as early as possible please
AccountsTrigger : Use below code
trigger AccountsTrigger on Account (after delete, after insert, after update, after undelete, before delete, before insert, before update) {
// Creates Domain class instance and calls appropriate methods
fflib_SObjectDomain.triggerHandler(Accounts.class);
}
Accounts Class : Use below code
public class Accounts extends fflib_SObjectDomain {
public Accounts(List<Account> sObjectList) {
super(sObjectList);
}
public class Constructor implements fflib_SObjectDomain.IConstructable {
public fflib_SObjectDomain construct(List<SObject> sObjectList) {
return new Accounts(sObjectList);
}
}
public override void onApplyDefaults()
{
for (Account acct : (List<Account>)Records) {
acct.Description = 'Domain classes rock!';
}
}
public override void onBeforeUpdate(Map<Id,sObject> existingRecords) {
String rock = 'Domain classes rock!';
List<Account> updatedAccounts = new List<Account>();
for(Account acc : (List<Account>) Records) {
acc.AnnualRevenue = rock.getLevenshteinDistance(acc.Description);
updatedAccounts.add(acc);
}
fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork(new Schema.SObjectType[] { Account.SObjectType });
uow.registerDirty(updatedAccounts);
}
}
Create a trigger named AccountsTrigger for Account that calls the fflib_SObjectDomain triggerHandler method for all trigger methods.
Try this
The 'Accounts' class 'onApplyDefaults' method does not appear to be setting the Description field to 'Domain classes rock!' correctly for a default value.
Accounts.apxc AccountsTrigger.apxt What am I missing here?