현재 사용자가 전환할 수 있는 테이블에 대해 사용하도록 설정된 비즈니스 프로세스 흐름을 비동기적으로 검색합니다.
Syntax
formContext.data.process.getEnabledProcesses(callbackFunction(enabledProcesses));
매개 변수
| 이름 | 유형 | 필수 | Description |
|---|---|---|---|
callbackFunction |
기능 | Yes | 콜백 함수는 속성 이름이 비즈니스 프로세스 흐름의 ID이고 속성 값이 비즈니스 프로세스 흐름의 이름인 사전 속성이 있는 개체를 포함하는 매개 변수를 허용해야 합니다. 활성화된 프로세스는 사용자의 권한에 따라 필터링됩니다. 사용하도록 설정된 프로세스 목록은 프로세스를 수동으로 변경하려는 경우 사용자가 UI에서 볼 수 있는 것과 동일합니다. |
Example
예제의 Sdk.formOnLoad 함수는 formContext.data.process.getEnabledProcesses 메서드를 사용하여 테이블에 대해 사용하도록 설정된 비즈니스 프로세스 흐름에 대한 정보를 비동기적으로 검색합니다. 샘플은 무명 함수를 첫 번째 매개 변수로 전달합니다. 이 함수는 데이터가 반환되고 데이터가 익명 함수에 매개 변수로 전달될 때 비동기적으로 실행됩니다.
사용 가능한 비즈니스 프로세스 흐름에 대한 정보는 프로세스의 ID가 속성의 이름이고 비즈니스 프로세스 흐름의 이름이 속성 값인 사전 개체로 제공됩니다. 샘플 코드는 이 정보를 처리하고 나중에 실행되는 논리에서 액세스할 전역 Sdk.enabledProcesses 배열의 값을 설정합니다. 또한 샘플은 Sdk.enabledProcesses 배열의 값을 반복하고 Sdk.writeToConsole 함수를 사용하여 검색된 비즈니스 프로세스 흐름에 대한 정보를 콘솔에 씁니다.
비고
샘플 JavaScript 라이브러리의 Sdk.formOnLoad 함수는 폼에 대한 OnLoad 이벤트 처리기로 설정해야 하며 처리기 속성 대화 상자에서 첫 번째 매개 변수로 실행 컨텍스트 전달 확인란을 선택해야 합니다.
또한 이 샘플에서는 formContext.data.process API에서 일부 메서드를 사용하는 방법을 보여 줍니다. 비즈니스 요구 사항을 충족하기 위해 이 API를 사용하는 것은 아닙니다. 코드에서 키 속성 값에 액세스할 수 있는 방법을 보여 주는 용도로만 사용됩니다.
//A namespace defined for SDK sample code
//You should define a unique namespace for your libraries
var Sdk = window.Sdk || {};
(function () {
//A global variable to store information about enabled business processes after they are retrieved asynchronously
this.enabledProcesses = [];
// A function to log messages while debugging only
this.writeToConsole = function (message) {
if (typeof console != 'undefined')
{ console.log(message); }
};
// Code to run in the OnLoad event
this.formOnLoad = function (executionContext) {
// Retrieve the formContext
var formContext = executionContext.getFormContext();
// Retrieve Enabled processes
formContext.data.process.getEnabledProcesses(function (processes) {
//Move processes to the global Sdk.enabledProcesses array;
for (var processId in processes) {
Sdk.enabledProcesses.push({ id: processId, name: processes[processId] })
}
Sdk.writeToConsole("Enabled business processes flows retrieved and added to Sdk.enabledProcesses array.");
//Write the values of the Sdk.enabledProcesses array to the console
if (Sdk.enabledProcesses.length < 0) {
Sdk.writeToConsole("There are no enabled business process flows for this table.");
}
else {
Sdk.writeToConsole("These are the enabled business process flows for this table:");
for (var i = 0; i < Sdk.enabledProcesses.length; i++) {
var enabledProcess = Sdk.enabledProcesses[i];
Sdk.writeToConsole("id: " + enabledProcess.id + " name: " + enabledProcess.name)
}
}
//Any code that depends on the Sdk.enabledProcesses array needs to be initiated here
});
};
}).call(Sdk);
브라우저 개발자 도구가 열려 있는 상태에서 이 샘플을 실행하는 경우 다음은 여러 비즈니스 프로세스 흐름이 활성화된 테이블에 대해 콘솔에 기록된 출력의 예입니다.
Enabled business processes flows retrieved and added to Sdk.enabledProcesses array.
These are the enabled business process flows for this table:
id: 7994be68-899e-4a40-8d18-f5c3b6940188 name: Sample Lead Process
id: 919e14d1-6489-4852-abd0-a63a6ecaac5d name: Lead to Opportunity Sales Process