# Basic DataSources

If you **simply want to query related objects**, use the basic data source settings.

Select the related object for the lookup or line item, and map the fields from the data source to the lookup or line item fields.

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

For example, if the Lookup object is specified as Product2 and you want to display the unit price from a PricebookEntry, you can use an internal data source to look up the PricebookEntry that meets the criteria, and display the product and unit price together.

* [**Properties**](#properties)

  Define each property of the internal DataSource.
* [**Actions**](#actions)

  Map data retrieved from an internal DataSource to a Lookup or Line-item.
* [**Example**](#example)

***

### Properties

<table><thead><tr><th width="192">Item</th><th width="450.3333333333333">Description</th><th>Req.</th></tr></thead><tbody><tr><td>Source Object</td><td>Specify the Salesforce objects that you want to source data from.</td><td><mark style="color:red;">✔️</mark></td></tr><tr><td>Query</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.</td><td></td></tr><tr><td>Active</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>Evaluation Event</td><td><p>When adding a DataSource for the Line-item Editor, an Evaluation Event needs to be specified.</p><ul><li>On Initialization: Executes when a new Line-item is added.</li><li>On Loading: Executes when the Line-item screen is loaded.</li><li>Before Save: Executes before a Line-item is saved.</li></ul></td><td></td></tr><tr><td><a href="#actions"><strong>Actions</strong></a></td><td>These are operations to map data imported via an internal DataSource to a Lookup or Line-item.</td><td><mark style="color:red;">✔️</mark></td></tr></tbody></table>

### Actions

These are operations to map data imported via an internal DataSource to a Lookup or Line-item.

<table><thead><tr><th width="183">Item</th><th width="466.33333333333326">Description</th><th>Req.</th></tr></thead><tbody><tr><td>Action Order</td><td>Specify the order that mappings are carried out.</td><td><mark style="color:red;">✔️</mark></td></tr><tr><td>Source Field</td><td>Specify the field to map from the internal DataSource object.</td><td><mark style="color:red;">✔️</mark></td></tr><tr><td>Target Field</td><td>Specify the Lookup or Line-item field to map to.</td><td><mark style="color:red;">✔️</mark></td></tr><tr><td>Key</td><td>If true, this mapping will define how to match records between the Lookup or Line-item objects and the DataSource object.<br><br>For example, if the Lookup is specified as Product2 and you import PricebookEntry as the DataSource, the key mapping would connect the field <code>Product2Id</code> from PricebookEntry (source field) and the field <code>Id</code> from Product2 (target field):<br><br><code>PriceBookEntry.Product2Id = Product2.Id</code></td><td><mark style="color:red;">✔️</mark></td></tr></tbody></table>

### Example

For example, when setting the lookup object as a product, it is often necessary to display price information along with it. However, in Salesforce, pricing is typically managed in Pricebook Entries. Since Pricebook Entries are child objects of Products, they cannot be fetched directly using formula fields.

To solve this issue, you can use a data source to query the Pricebook Entry for each product and display the information in the lookup selector or line item editor.

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

1. In the DataSource settings, specify the Source Object as PricebookEntry.
2. (optional) Use the Query Wizard to create conditions for the query (same as SOQL `WHERE` statement).
3. To match the PricebookEntry data to the Products, use the following settings:
   * Source Field: `Product2Id`
   * Target Field: `Id`
   * Key: true
4. Add an Action to configure a Lookup column to display the unit price together with the Product data.
   * Source Field: UnitPrice
   * Target Field: SBLDVirtual1 ([Virtual fields reference](/smallbuilder-line-items/setup/setup-lookup-selector.md#virtual-column))

<figure><img src="/files/2vLZY4QB5AOOUuIzpn15" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/jrVzI4Vto0bblxVLN6Qf" 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/setup/datasource/internal.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.
