# Basic DataSource: Retrieve Related Object Data

If you want to **simply fetch related object data**, consider using Basic DataSource settings. You can select an object related to Lookup or Line Item and map the fields of the retrieved object to the Lookup or Line Item fields via DataSource.

<figure><img src="/files/SYmEIHDEnnJiK6jUZWT3" alt="" width="375"><figcaption></figcaption></figure>

### Basic DataSource Settings

<figure><img src="/files/D6wTEiLClfx0PisBz7mw" alt=""><figcaption></figcaption></figure>

<table><thead><tr><th width="82">No.</th><th width="165">Attribute</th><th width="418.3333333333333">Description</th><th>Req.</th></tr></thead><tbody><tr><td><strong>1</strong></td><td><strong>Source Object</strong></td><td>Specify the Salesforce objects that you want to source data from.</td><td><mark style="color:red;">✔</mark></td></tr><tr><td><strong>2</strong></td><td><strong>Query</strong></td><td>Click the Wizard button to open the Build Query layout. You can use the Query Wizard to easily build queries by searching for the correct fields to use.<br>Filters are entered in the format of a SOQL <code>WHERE</code> clause.</td><td></td></tr><tr><td><strong>3</strong></td><td><strong>Evaluation Event</strong></td><td><p>Set the execution timing for the DataSource.</p><ul><li><strong>On Initialization:</strong> Executes when a new Line Item is added.</li><li><strong>On Loading:</strong> Executes when the Line Item screen is loaded.</li><li><strong>Before Save:</strong> Executes before a Line Item is saved.</li></ul><p><span data-gb-custom-inline data-tag="emoji" data-code="2757">❗</span> <em><mark style="color:red;">Available only for Line Items.</mark></em></p></td><td></td></tr><tr><td><strong>4</strong></td><td><strong>Active</strong></td><td>Turns the DataSource on or off. It must be active to be used.</td><td><mark style="color:red;">✔</mark></td></tr><tr><td><strong>5</strong></td><td><a href="#actions"><strong>Actions</strong></a></td><td>Map the fields from the DataSource object to the Lookup or Line Item fields.</td><td><mark style="color:red;">✔</mark></td></tr></tbody></table>

### Actions

Actions involve mapping the data fetched from the DataSource to the fields in Lookup or Line Items. Through these actions, the DataSource values are applied to the designated fields.

<figure><img src="/files/inGp8vlS50U9lBZzS718" alt=""><figcaption></figcaption></figure>

<table><thead><tr><th width="80">No.</th><th width="133">Attribute</th><th width="423.33333333333326">Description</th><th>Req.</th></tr></thead><tbody><tr><td><strong>1</strong></td><td><strong>Order</strong></td><td>Specify the order that mappings are carried out.</td><td><mark style="color:red;">✔</mark></td></tr><tr><td><strong>2</strong></td><td><strong>Source Field</strong></td><td>Select the field from the DataSource object.</td><td><mark style="color:red;">✔</mark></td></tr><tr><td><strong>3</strong></td><td><strong>Target Field</strong></td><td>Select the target field in Lookup or Line Item where the data will be mapped.</td><td><mark style="color:red;">✔</mark></td></tr><tr><td><strong>4</strong></td><td><strong>Key</strong></td><td>The unique identifier used for mapping data between the DataSource and Lookup or Line Item. The Key determines the target for the mapped DataSource values.</td><td><mark style="color:red;">✔</mark></td></tr></tbody></table>

### Example

{% hint style="info" %}
This example demonstrates the configuration of a Line Item Editor for Opportunity Products:

* **Parent:** Opportunity
* **Line Item:** OpportunityLineItem
* **Lookup:** Product2
  {% endhint %}

When the **Lookup Object** is set to **Product2**, users often **want to display UnitPrice information.** However, in Salesforce, **the UnitPrice is stored in the PricebookEntry object**, which is a child object of Product. Since UnitPrice cannot be fetched via a formula field, we use a DataSource to query the related PricebookEntry data.

<figure><img src="/files/9vXw6b1dBqqoHJpAiUVc" alt="" width="375"><figcaption></figcaption></figure>

<figure><img src="/files/6PietXlfWUw9A2jOdmle" alt="" width="563"><figcaption></figcaption></figure>

1. In the DataSource settings, specify the Source Object as **PricebookEntry**.
2. (optional) Click **Query Wizard** to set up the query conditions:\
   `IsActive = true AND Pricebook2Id = {$Parent.Pricebook2Id}`
3. To match the PricebookEntry data to the Products, use the following settings:
   * Source Field: `Product2Id`
   * Target Field: `Id`
   * Key: `true`
4. To display the Unit Price alongside the product data, add an Action and map the fields to a[ virtual column](/smallbuilder-lists/builder-setup-steps/datatable-setup/add-virtual-column.md) in Lookup:
   * Source Field: `UnitPrice`
   * Target Field: `SBLI_Virtual1`

<figure><img src="/files/JpJPGTpvV40gfc3ZvSiY" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/KJGpmWyfZlQIJ4UkI65g" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/78w75KZGRhXS81ghYIRv" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.smallbuilder.com/smallbuilder-line-items/builder/business-rule/basic.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
