getFormContext (クライアント API 参照)

呼び出された場所によってフォーム上のフォームまたはアイテムへの参照を返します。

構文

ExecutionContextObj.getFormContext()

戻り値

種類: オブジェクト

説明: メソッドが呼び出された場所に基づいて、編集可能グリッドなどの、フォームへの参照またはフォーム上のアイテムを返します。 このメソッドによって、呼び出される場所によってフォーム上のフォームまたはアイテム上のいずれかに操作ができるイベント ハンドラーの作成が可能となります。

次のサンプルコードは、スクリプトを登録した場所に応じて、フォームの列や編集可能なグリッドセルに通知を設定するメソッドを作成する方法を示しています (列の OnChangeイベントまたは編集可能なグリッドの OnChange イベント):

function commonEventHandler(executionContext) {
    var formContext = executionContext.getFormContext();    
    var telephoneAttr = formContext.data.entity.attributes.get('telephone1');
    var isNumberWithCountryCode = telephoneAttr.getValue().substring(0,1) === '+';

    // telephoneField will be a form control if invoked from a form OnChange event;
    // telephoneField will be a editable grid GridCell object if invoked from editable grid OnChange event.
    var telephoneField = telephoneAttr.controls.get(0);

    if (!isNumberWithCountryCode) {
        telephoneField.setNotification('Please include the country code beginning with '+'.', 'countryCodeNotification');
    }
    else {
        telephoneField.clearNotification('countryCodeNotification');
    }
}

実行コンテキスト
フォーム コンテキスト

注意

ドキュメントの言語設定についてお聞かせください。 簡単な調査を行います。 (この調査は英語です)

この調査には約 7 分かかります。 個人データは収集されません (プライバシー ステートメント)。