이 메서드는 addCustomFilter 모델 기반 앱의 조회 컨트롤에 표시되는 결과에 필터를 추가합니다. 각 필터는 이전에 추가된 필터와 조건으로 AND 결합됩니다.
지원되는 컨트롤 형식
Lookup
Syntax
formContext.getControl(arg).addCustomFilter(filter, entityLogicalName)
매개 변수
| 이름 | Type | Description |
|---|---|---|
filter |
스트링 | 적용할 FetchXML 필터 요소입니다. |
entityLogicalName |
스트링 | Optional. 이 매개 변수를 설정하는 경우 필터는 해당 테이블 형식에만 적용됩니다. 그렇지 않으면 반환된 모든 유형의 테이블에 적용됩니다. |
예를 들어 매개 변수에 다음 XML을 filter 사용합니다.
<filter type="and">
<condition attribute="address1_city" operator="eq" value="Redmond" />
</filter>
비고
Lookup Control PreSearch 이벤트에 대한 이벤트 처리기의 함수에서 이 메서드를 사용합니다.
Example
다음 코드 샘플은 기회 양식 계정 (parentaccountid) 조회를 위한 것입니다. 폼 Onload 이벤트 처리기에서 함수를 설정할 Sdk.setParentAccountIdFilter 때 해당 조회에 PreSearch 대한 이벤트에 함수를 추가 Sdk.filterCustomerAccounts 합니다. 폼 Onload 이벤트 처리기에서 함수를 설정할 때 실행 컨텍스트에 전달하는 옵션을 선택해야 합니다. 그 결과 기본 설정 고객(1)의 범주(accountcategorycode) 값이 있는 계정만 반환됩니다.
// A namespace defined for SDK sample code
// You should define a unique namespace for your libraries
const Sdk = (window.Sdk ??= {});
// set 'Sdk.setParentAccountIdFilter' in the Opportunity form onload event handler
Sdk.setParentAccountIdFilter = (executionContext) => {
const formContext = executionContext.getFormContext();
formContext.getControl("parentaccountid").addPreSearch(Sdk.filterCustomerAccounts);
};
Sdk.filterCustomerAccounts = (executionContext) => {
const control = executionContext.getEventSource();
const customerAccountFilter = `
<filter type="and">
<condition attribute="accountcategorycode" operator="eq" value="1" />
</filter>`;
control.addCustomFilter(customerAccountFilter, "account");
};