In relation to the code below, is the "AccountId" a standard field in the opportunity object? I don't think the last code (acc.Id = opp.AccountId) is valid.

for (Opportunity opp : Trigger.new) {
    // Make sure we meet the minimum threshold
    if (opp.Amount >= OPP_MIN_VALUE) {
      // This is a trick to get the related account
      Account acc = new Account();
      acc.Id      = opp.**AccountId**;

1 Answer 1


You can see for yourself, AccountId is the first field listed in the documentation on the Opportunity object.

No hard-coded reference to a field which does not exist will even compile.

Opportunity opp;
// loop record, for example

opp.BogusField = 'Some Value';
// this line will not compile

opp.put('DynamicField', 'Some Value');
// this line will compile but will cause a runtime error
// though it will work if you replace 'DynamicField' with a proper API Name

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .