getActivePath (クライアント API 参照)
業務プロセス フローのコントロールに表示されるステージを操作するメソッドで、現在アクティブ パスにあるステージのコレクションを取得します。
アクティブ パスは、分岐ルールとレコードの最新のデータに基づいてプロセス コントロールで現在表示されているステージを表します。
構文
var stageCollection = formContext.data.process.getActivePath();
注意
エンティティとテーブルの違いがわかりませんか? Microsoft Dataverse で「開発者: 用語を理解する」を参照してください。
戻り値
種類: コレクション。
説明: すべての完了したステージ、現在アクティブなステージ、および分岐ルールの条件に基づいて予測される今後の一連のステージのコレクションです。 状況によっては、formContext.data.process.getActiveProcess によって返されるステージのサブセットとなります。これは、プロセスで発生する分岐に基づき、現在のステージからの有効な遷移を表すステージのみを含むからです。
例
Sdk.formOnLoad 関数は、formContext.data.process.getActivePath メソッドを使用して、ステージのコレクションを取得します。 次に、このサンプル コードは、コレクションの forEach メソッドを使用して、各ステージをループします。 次に、このコードは、このライブラリで定義されている Sdk.writeToConsole 関数を使用して、ステージの主要なプロパティをコンソールに書き込みます。 次にコードは、getSteps メソッドを使用して、各ステージのステップのコレクションにアクセスします。 最後に、このサンプルは、ステップ コレクションの forEach メソッドを使用して、各ステップにアクセスし、ステップの主要なプロパティをコンソールに書き込みます。
注意
サンプルの JavaScript ライブラリに含まれる関数は Sdk.formOnLoad 関数を、フォームの OnLoad イベント ハンドラーとして設定し、ハンドラーのプロパティ ダイアログで、実行コンテキストを最初のパラメーターとして渡す チェック ボックスを選択する必要があります。
また、このサンプルでは、formContext.data.processAPI のいくつかのメソッドの使用方法についても示しています。 その目的は、この API を使用してビジネス要件を満たす方法を説明することではなく、主なプロパティ値にコードでアクセスする方法を説明することです。
// A namespace defined for SDK sample code
// You should define a unique namespace for your libraries
var Sdk = window.Sdk || {};
(function () {
// 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();
// Enumerate the stages and steps in the active path
var activePathCollection = formContext.data.process.getActivePath();
activePathCollection.forEach(function (stage, n) {
Sdk.writeToConsole("Stage Index: " + n);
Sdk.writeToConsole("Table: " + stage.getEntityName());
Sdk.writeToConsole("StageId: " + stage.getId());
Sdk.writeToConsole("Status: " + stage.getStatus());
var stageSteps = stage.getSteps();
stageSteps.forEach(function (step, i) {
Sdk.writeToConsole(" Step Name: " + step.getName());
Sdk.writeToConsole(" Step Column: " + step.getAttribute());
Sdk.writeToConsole(" Step Required: " + step.isRequired());
Sdk.writeToConsole(" ---------------------------------------")
})
Sdk.writeToConsole("---------------------------------------")
});
};
}).call(Sdk);
ブラウザーでサンプルを実行すると、ブラウザーの開発者ツールを使用して、コンソールに書き込まれるテキストを表示できます。 たとえば、このサンプルを営業案件フォームで営業案件の営業プロセスで実行すると、次のような内容がコンソールに書き込まれます:
Stage Index: 0
Table: opportunity
StageId: 6b9ce798-221a-4260-90b2-2a95ed51a5bc
Status: active
Step Name: Identify Contact
Step Column: parentcontactid
Step Required: false
---------------------------------------
Step Name: Identify Account
Step Column: parentaccountid
Step Required: false
---------------------------------------
Step Name: Purchase Timeframe
Step Column: purchasetimeframe
Step Required: false
---------------------------------------
Step Name: Estimated Budget
Step Column: budgetamount
Step Required: false
---------------------------------------
Step Name: Purchase Process
Step Column: purchaseprocess
Step Required: false
---------------------------------------
Step Name: Identify Decision Maker
Step Column: decisionmaker
Step Required: false
---------------------------------------
Step Name: Capture Summary
Step Column: description
Step Required: false
---------------------------------------
---------------------------------------
Stage Index: 1
Table: opportunity
StageId: 650e06b4-789b-46c1-822b-0da76bedb1ed
Status: inactive
Step Name: Customer Need
Step Column: customerneed
Step Required: false
---------------------------------------
Step Name: Proposed Solution
Step Column: proposedsolution
Step Required: false
---------------------------------------
Step Name: Identify Stakeholders
Step Column: identifycustomercontacts
Step Required: false
---------------------------------------
Step Name: Identify Competitors
Step Column: identifycompetitors
Step Required: false
---------------------------------------
---------------------------------------
Stage Index: 2
Table: opportunity
StageId: d3ca8878-8d7b-47b9-852d-fcd838790cfd
Status: inactive
Step Name: Identify Sales Team
Step Column: identifypursuitteam
Step Required: false
---------------------------------------
Step Name: Develop Proposal
Step Column: developproposal
Step Required: false
---------------------------------------
Step Name: Complete Internal Review
Step Column: completeinternalreview
Step Required: false
---------------------------------------
Step Name: Present Proposal
Step Column: presentproposal
Step Required: false
---------------------------------------
---------------------------------------
Stage Index: 3
Table: opportunity
StageId: bb7e830a-61bd-441b-b1fd-6bb104ffa027
Status: inactive
Step Name: Complete Final Proposal
Step Column: completefinalproposal
Step Required: false
---------------------------------------
Step Name: Present Final Proposal
Step Column: presentfinalproposal
Step Required: false
---------------------------------------
Step Name: Confirm Decision Date
Step Column: finaldecisiondate
Step Required: false
---------------------------------------
Step Name: Send Thank You
Step Column: sendthankyounote
Step Required: false
---------------------------------------
Step Name: File De-brief
Step Column: filedebrief
Step Required: false
---------------------------------------
---------------------------------------
関連トピック
注意
ドキュメントの言語設定についてお聞かせください。 簡単な調査を行います。 (この調査は英語です)
この調査には約 7 分かかります。 個人データは収集されません (プライバシー ステートメント)。
フィードバック
フィードバックの送信と表示