플로우 - 범위 지정 (사용하지 않음)
플로우 API는 활성화된 워크플로우 스튜디오 플로우를 실행하는 메서드를 제공합니다.
이 API는 더 이상 사용되지 않으며 및 ScriptableFlowRunnerResult - 범위 지정됨API로 대체됩니다ScriptableFlowRunner - 범위 지정됨.
플로우 API는 서버 스크립트에서만 사용할 수 있습니다.
sn_fd 네임스페이스를 사용하여 플로우 API에 액세스합니다.
플로우 API를 사용하여 플로우와 상호작용하기 전에 먼저 인터페이스에서 플로우 워크플로우 스튜디오 를 생성하고 활성화해야 합니다. Flow API는 사전 구축된 플로우와만 상호 작용하므로 클래스에 대한 생성자가 없습니다.
주:
인스턴스 성능을 최적화하려면 비동기 비즈니스 규칙 스크립트에서 이러한 메서드를 호출하지 마십시오. 대신 UI 내에서 워크플로우 스튜디오 예약된 작업 기록을 생성합니다.
플로우 - startAsync(String scopeName.flowName, map flowInputs)
트리거를 무시하고 활성화된 플로우를 비동기식으로 실행합니다.
비동기 호출은 비차단이므로 클라이언트가 플로우가 완료될 때까지 기다릴 필요 없이 스크립트의 다른 코드를 실행할 수 있습니다.
| 이름 | 유형 | 설명 |
|---|---|---|
| scopeName.flowName | 문자열 | 플로우의 애플리케이션 범위와 실행할 플로우의 내부 이름입니다. scopeName이 포함되지 않은 경우 현재 로그인한 사용자의 범위가 사용됩니다. 방문 페이지의 내부 이름 열을 워크플로우 스튜디오 사용하여 플로우의 내부 이름을 검색합니다. |
| flowInputs를 입력합니다. | 지도 | 기록 기반 플로우 입력을 정의하는 <문자열, 객체> 형식의 이름-값 쌍입니다.기록 기반 트리거로 플로우를 호출하려면 다음 형식을 사용합니다.
GlideRecord 개체의 이름은 'current'여야 합니다. 트리거로 서비스 카탈로그 플로우를 호출하려면 다음 형식을 사용합니다.
GlideRecord 객체의 이름은 'request_item'여야 합니다. |
| 유형 | 설명 |
|---|---|
| 객체 | 다음 속성을 포함하는 PlanResponse 객체입니다.
플로우가 다음과 같은 경우 예외가 발생합니다.
|
//Example 1: Run a flow with a record-based trigger
(function startFlowAsync() {
try {
// You MUST fetch the GlideRecord that will be passed to the flow
var glideRecordInput = new GlideRecord('sys_user');
glideRecordInput.get('62826bf03710200044e0bfc8bcbe5df1');
var flowInputs = {};
flowInputs['current'] = glideRecordInput;
flowInputs['table_name'] = glideRecordInput.getTableName();
var result = sn_fd.Flow.startAsync('global.recordtriggeredflow', flowInputs);
//The Sys ID of a flow execution (contextId)
var contextId = result.contextId;
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
//Example 2: Run a flow with a schedule-based trigger
(function startFlowAsync() {
try {
var result = sn_fd.Flow.startAsync('global.scheduletriggeredflow');
//The Sys ID of a flow execution (contextId)
var contextId = result.contextId;
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
//Example 3: Run a flow with a Service Catalog trigger
(function startFlowAsync() {
try {
// You MUST fetch the GlideRecord that will be passed to the flow
var glideRecordInput = new GlideRecord('sc_req_item');
glideRecordInput.get(aeed229047801200e0ef563dbb9a71c2);
var flowInputs = {};
flowInputs['request_item'] = glideRecordInput;
flowInputs['table_name'] = glideRecordInput.getTableName();
var result = sn_fd.Flow.startAsync('global.catalogtriggeredflow', flowInputs);
//The Sys ID of a flow execution (contextId)
var contextId = result.contextId;
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();
//Example 4: Run a flow with a MetricBase trigger
(function startMetricBaseFlowAsync() {
try {
var oilLevelTriggerRecord = new GlideRecord('oil_levels');
oilLevelTriggerRecord.get('a4b3622bc72113007b237f48cb97635f');
var metricTriggerDefinition = new GlideRecord('sys_metric_trigger_definition');
metricTriggerDefinition.get('21f2eae7c72113007b237f48cb976352');
var event_time = oilLevelTriggerRecord.getValue('sys_created_on');
var level = 4;
var metricBaseFlowInputs = {};
//The record that triggered the metric event
metricBaseFlowInputs['current'] = oilLevelTriggerRecord;
//The MetricBase Trigger Definition record
metricBaseFlowInputs['metric'] = metricTriggerDefinition;
//The time that the 'record' reached a specific metric event level and triggered this flow
metricBaseFlowInputs['event_time'] = event_time;
//The target event level to reach in order for a metric flow to trigger
metricBaseFlowInputs['level'] = level;
var result = sn_fd.Flow.startAsync('global.metricbasedtriggeredflow', metricBaseFlowInputs);
//The Sys ID of a flow execution (contextId)
var contextId = result.contextId;
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})();