検証スクリプトの構成

  • リリースバージョン: Washingtondc
  • 更新日 2024年02月01日
  • 読む4読むのに数分
  • DataImportValidationConfig スクリプトインクルードを使用して、ステージングテーブルの検証ルールを設定します。

    始める前に

    必要なロール:sn_customerservice.customer_admin

    このタスクについて

    ステージングテーブルのフィールドレベルとレコードレベルの検証ルールを定義します。これらの検証ルールは、ステージングテーブルにデータをインポートした後にエージェントが [検証 ] ボタンを選択するとトリガーされます。詳細については、「Playbook への アカウントライフサイクルイベント データのインポート」を参照してください。

    手順

    1. 移動先 すべて > 管理 > スクリプトインクルード.
    2. Account Life cycle Events アプリケーションを検索し、 DataImportValidationConfig スクリプトインクルードを選択します。
      ベースシステムで提供されるデフォルトのテーブルに対して定義されている検証ルールを確認できます。
    3. 次の 3 つのタイプの入力規則を定義できます。
      • 必須フィールド:ステージングテーブルに存在する必須フィールドを指定します。

        例:「 sn_acct_lc_account_onb_import_contacts テーブルで、次のフィールドが必須であることを指定できます。

        「u_account」、「u_email」、「u_last_name」

      • 参照フィールド:ステージングテーブルの参照フィールドを指定します。参照フィールドには、別のテーブルのフィールドへの参照が格納されます。参照フィールドを定義すると、2 つのテーブル間に関係が作成されます。
        例: sn_acct_lc_account_onb_import_contacts テーブルでは、次のように参照フィールドの検証を定義できます。
        "sn_acct_lc_account_onb_import_contacts": {
        		'u_account': {
        			'table_name': 'customer_account',
        			'reference_field': 'name'
        		}
        ここで 、u_account はステージングテーブルのフィールドの名前、 customer_account はテーブル、 name は関連付けられている参照フィールドです。
      • カスタム検証:ステージングテーブルレコードを検証するカスタムスクリプトを定義します。カスタム検証スクリプトの例を次に示します。
        dataImportCustomValidationForCustomerContacts: function(stagingTableGr){
        		try{
                    if(this.debuggingEnabled)
                        this.logs.push('Inside dataImportCustomValidationForCustomerContacts');
        			//Check the Account field's value coming from Excel is matching the corresponding Task or not.
        			while(stagingTableGr.next()){
        				if (global.JSUtil.notNil(stagingTableGr.task) && global.JSUtil.notNil(stagingTableGr.u_account)){
        					if (stagingTableGr.task.company.name != stagingTableGr.u_account){
        						sn_acct_lc.DataImportValidationFunctions.updateStagingTableRecordValidationComments(stagingTableGr, false, 'The Account is not matching with the Case Account.');
        					}
        				}
        			}
        		}
        		catch (err){
        			gs.error('Error while executing - dataImportCustomValidationForCustomerContacts - '+err);
        			if(this.debuggingEnabled)
        				this.logs.push('Error while executing - dataImportCustomValidationForCustomerContacts - '+err);
        			//Update the Validation Comments with the Error
        			sn_acct_lc.DataImportValidationFunctions.updateStagingTableRecordValidationComments(stagingTableGr, false, gs.getMessage('sn_acct_lc.DataImportValidationUtil.ValidationFailed', 'Custom'));
        		}
        	},

        前の例では、 dataImportCustomValidationForCustomerContacts がカスタム検証スクリプトです。この関数は、ステージングテーブルにアップロードされたすべてのレコードを含む stagingTableGr 変数 (GlideRecord 変数) を呼び出します。スクリプトは、 DataImportValidationFunctions を使用して指定された条件をチェックし、データを検証します。

      前の例で示した形式で、新しいステージングテーブルの 1 つ以上のスクリプトを定義できます。

    4. [ 更新 ] を選択して、スクリプトインクルードに加えた変更を保存します。