# 관련 개체 데이터 가져오기

{% hint style="warning" %}
버전 1.37부터 ‘**데이터소스(Data Source)**’가 ‘**비즈니스 규칙(Business Rule)**’으로 명칭이 변경되었습니다.
{% endhint %}

**단순히 관련된 개체를 조회**하려는 경우, 해당 비즈니스 규칙을 사용해보세요. 조회 또는 라인 아이템과 관련된 개체를 선택하고, 비즈니스 규칙을 통해 가져온 개체의 필드 값을 조회 또는 라인 아이템 필드에 매핑할 수 있습니다.

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

***

### 관련 개체를 이용한 비즈니스 규칙 설정

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

<table><thead><tr><th width="87">번호</th><th width="117">항목</th><th width="446.33333333333326">설명</th><th>필수</th></tr></thead><tbody><tr><td><strong>1</strong></td><td>소스 개체</td><td>데이터를 가져올 개체를 선택합니다.</td><td><mark style="color:red;">✔</mark></td></tr><tr><td><strong>2</strong></td><td>설명</td><td>비즈니스 규칙에 대한 설명을 기재합니다.</td><td></td></tr><tr><td><strong>3</strong></td><td>필터 조건</td><td>필터 설정 방법</td><td></td></tr><tr><td><strong>4</strong></td><td>평가 이벤트</td><td><p>비즈니스 규칙의 <strong>실행 시점</strong>을 설정합니다.</p><ul><li><strong>초기화 시(On Initialization):</strong> 라인 아이템 레코드가 새로 추가될 때 실행됩니다.</li><li><strong>로딩 시(On Loading):</strong> 라인 아이템 화면이 로드될 때마다 실행됩니다.</li><li><strong>변경 시(On Change):</strong> 라인 아이템의 특정 필드가 변경될 때마다 실행됩니다.</li><li><strong>저장 전(Before Save):</strong> 라인 아이템 레코드가 저장되기 전에 실행됩니다.</li></ul><p><span data-gb-custom-inline data-tag="emoji" data-code="2757">❗</span> <em><mark style="color:red;">라인 아이템에서만 제공되는 설정입니다.</mark></em></p></td><td><mark style="color:red;">✔</mark></td></tr><tr><td><strong>5</strong></td><td><a href="#undefined-1">작업</a></td><td>비즈니스 규칙으로 가져온 데이터를 조회 또는 라인 아이템 필드와 매핑합니다.</td><td><mark style="color:red;">✔</mark></td></tr></tbody></table>

### 작업

비즈니스 규칙을 통해 가져온 데이터를 조회 또는 라인 아이템 필드와 매핑하는 작업입니다. 이 작업을 통해 비즈니스 규칙 값이 지정된 필드에 반영됩니다.

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

<table><thead><tr><th width="63.70703125">번호</th><th width="157.58984375">항목</th><th width="466.33333333333326">설명</th><th>필수</th></tr></thead><tbody><tr><td><strong>1</strong></td><td>Key</td><td>비즈니스 규칙과 조회 또는 라인 아이템 간 데이터 매핑 시 사용할 고유 식별 값입니다. Key를 기준으로 비즈니스 규칙 값이 매핑될 대상을 결정합니다.</td><td></td></tr><tr><td><strong>2</strong></td><td>규칙 필드</td><td>비즈니스 규칙의 소스 개체에서 가져올 필드를 선택합니다.</td><td><mark style="color:red;">✔</mark></td></tr><tr><td><strong>3</strong></td><td>조회/라인 아이템 필드</td><td>데이터를 매핑할 조회 또는 라인 아이템의 필드를 선택합니다.</td><td><mark style="color:red;">✔</mark></td></tr></tbody></table>

### 예시: 제품의 단가 표시

{% hint style="info" %}
이 예시에서는 기회 제품에 대한 라인 아이템 편집기를 설정하였습니다.

* **부모:** 기회(`Opportunity`)
* **라인 아이템:** 기회 제품(`OpportunityLineItem`)
* **조회:** 제품(`Product2`)
  {% endhint %}

조회 개체를 제품(`Product2`)으로 설정한 경우, 사용자들은 일반적으로 단가(`UnitPrice`) 정보를 함께 표시하고 싶어합니다. 하지만 세일즈포스에서는 단가 정보가 가격 목록 항목(`PricebookEntry`) 개체에 저장되어 있습니다. 그러나 가격 목록 항목은 제품의 하위 개체로, 단가 정보를 수식 필드로 가져올 수 없습니다. 따라서 제품과 연결된 가격 목록 항목 데이터를 비즈니스 규칙을 이용해 조회하려고 합니다.

<figure><img src="/files/8iADoFX7uvPdc5wx6jX7" alt=""><figcaption></figcaption></figure>

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

#### 설정

1. 조회 선택기 설정 단계에서 조회 필드에 **통화 유형의 가상 열을 추가**합니다.
2. 바로 하단에 비즈니스 규칙의 ‘**관련 객체에서 데이터 가져오기**’ 레이아웃에서 **비즈니스 규칙 추가**를 클릭합니다.
3. 비즈니스 규칙에서 **소스 개체(Source Object)**&#xB97C; 가격 목록 항목(`PricebookEntry`)로 지정합니다.
4. 필터 설정에서 개체 조회 조건을 설정합니다.
   * **활성화**
     1. **필드:** 활성(IsActive)
     2. **연산자:** 같음(equals)
     3. **값:** 참(true)
   * **기회와 동일한 가격 목록**
     1. **필드:** 가격 목록(Pricebook2Id)
     2. **연산자:** 같음(equals)
     3. **값:** 부모/가격 목록(Pricebook2Id)
5. **작업(Action) 설정**에서 각 제품에 해당되는 가격 목록 항목 데이터를 결합하기 위해 다음과 같이 설정합니다:
   * **규칙:** `Product2Id`
   * **조회:** `Id`
6. 단가를 제품 데이터와 같이 표시하기 위해 **작업(Action)**&#xC744; 추가하여 조회 필드([가상 열](https://github.com/Windmillsoft/smallbuilder-help-kr/blob/main/smallbuilder-line-items/builder/datasource/broken-reference/README.md))을 지정합니다.
   * **규칙:** `UnitPrice`
   * **조회:** `SBLI_Virtual1`

<figure><img src="/files/vFFXSuGN5c2RjSmVAwzS" alt=""><figcaption><p>조회 필드에서 단가 정보를 표시할 가상 열을 추가합니다.</p></figcaption></figure>

<figure><img src="/files/276l0DCEifwTMKwIxmfu" alt=""><figcaption><p>비즈니스 규칙 설정 화면입니다.</p></figcaption></figure>

<figure><img src="/files/3wSOvBWQ7rVGL2534Uco" alt=""><figcaption></figcaption></figure>

#### 결과

조회 선택기에서 제품에 대한 **데이터소스를 통해 가져온 단가 정보**가 함께 표시되는 것을 확인할 수 있습니다.

<figure><img src="/files/wmU84YeHXVBDoepyyVCv" 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/ko/smallbuilder-line-items/builder/datasource/object.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.
