I'm attempting to self learn Salesforce and want to add a custom field to an Account.
To achieve this I've done the following:
I've added the Total custom field to Account:
Here is the trigger:
trigger AccountTotalTrigger on Account (before insert) {
List<String> accountNames = new List<String>{};
//Loop through all records in the Trigger.new collection
for(Account a: Trigger.new){
//Concatenate the Name and billingState into the Description field
a.Description = a.Name + ':' + a.BillingState;
}
}
and accompanying test:
@IsTest
private with sharing class AccountsTest {
@IsTest
static void testAccountTriggerViaDML()
{
// This example is simple, illustrates how to invoke the trigger code via DML (required),
// but can become complex and detract from TDD and more granularly testing of the Accounts class
Account testAccount = new Account( Name = 'Test Account' , Total = 100 );
insert testAccount;
testAccount = [select Id, Name from Account where Id = :testAccount.Id];
System.assertEquals(testAccount.Name, 'Test Account');
}
}
But there is a problem on the Problems tab:
the message is: Field does not exist: Total on Account
Have I not setup the Account field correctly?
Should the test not be failing? It appears to pass: