2.2 Use relationship to retrieve data from related objects

Before we start

Besides our current merchandise object, we need to quickly create two custom objects – Customer and Transaction. Customer object has one custom field called Address which is a text field and Transaction object has two lookup relationship fields pointing to Customer and Transaction. Don’t forget to create tabs for both objects as well. Create a few records for both objects.

• • •

2.1 Use SOQL and where statement to retrieve data

The concept

In the last chapter, we have talked about how to use DML statements and Database methods to modify data from Salesforce database. In this chapter, I will show you how to retrieve data. Apex used a feature called SOQL language to retrieve the data. And SOQL statements are first class citizens in Apex as well.

• • •