• Deepali Bhangale
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I am working on the Developer Beginner trailhead. One of the exercises is below:

-----------
Contact jane = new Contact(FirstName='Jane',
                         LastName='Smith',
                         Email='jane.smith@example.com',
                         Description='Contact of the day');
insert jane;

// 1. Upsert using an idLookup field
// Create a second sObject variable.
// This variable doesn’t have any ID set.
Contact jane2 = new Contact(FirstName='Jane',
                         LastName='Smith',  
                         Email='jane.smith@example.com',
                         Description='Prefers to be contacted by email.');
// Upsert the contact by using the idLookup field for matching.
upsert jane2 Contact.fields.Email;

// Verify that the contact has been updated
System.assertEquals('Prefers to be contacted by email.',
                   [SELECT Description FROM Contact WHERE Id=:jane.Id].Description);

-------------
I understand the gist of the code, but cannot find a reference in the Apex documentation about the syntax within the bolded lines. Would someone break down each piece of this code for me? In particular why does the [Select...].Description phrase require the .Description?

My dilemma has been that I have a great deal of experience with programming, but not with Java. So much of the material I'm finding assumes knowledge of Jave syntax.