---
sourceDocument: Xanadu API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - ja-JP

ft:publication_title :

    - Xanadu API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# ServiceNow Fluent

# ServiceNow Fluent {#ariaid-title1}

* リリースバージョン: Xanadu
* 
* 更新日 2024年08月01日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：5分

ServiceNow Fluent ドメイン固有のプログラミング言語を使用して、ソースコードでアプリケーションメタデータを定義します。

## 概要 {#servicenow-fluent__section_jnb_vvg_z1c}

ServiceNow Fluent は、アプリケーションを構成するメタデータファイル \[sys_metadata\] を定義するための TypeScript に基づくドメイン固有言語 (DSL) であり、テーブル、ロール、ACL、ビジネスルール、自動テストフレームワーク (ATF) テストなど、さまざまなタイプのメタデータの API が含まれています。

開発者は、フォームやビルダーツールのユーザーインターフェイスではなく、数行のコードでこのメタデータを定義します。ServiceNow IDE または ServiceNow SDK で作成されたアプリケーションは、ServiceNow Fluent での開発をサポートします。  
ServiceNow Fluent は双方向同期をサポートしています。これにより、メタデータへの変更を他の Now Platform ユーザーインターフェイスからソースコードに同期し、ソースコードへの変更をインスタンス全体のメタデータに同期することができます。  
注:  
自動テストフレームワーク (ATF) のテスト API は一方向の同期のみをサポートします。ソースコードで ATF テストを定義した後、メタデータがソースコードの外部で変更された場合、それらの変更は同期されず、ソースコードに反映されません。

ServiceNow IDE または ServiceNow SDK の使用を開始するには、『[ServiceNow IDE](https://www.servicenow.com/docs/access?context=servicenow-ide-landing&version=xanadu&pubname=xanadu-application-development&ft:locale=en-US)』または『[ServiceNow SDK](https://www.servicenow.com/docs/access?context=servicenow-sdk-landing&version=xanadu&pubname=xanadu-application-development&ft:locale=en-US)』のドキュメントを参照してください。

## API {#servicenow-fluent__section_nyj_y13_zbc}

ServiceNow Fluent には、次のタイプのメタデータの API が含まれています。レコード API を使用して、専用 API を持たないアプリケーションメタデータを定義できます。API と例の詳細については、「[ServiceNow Fluent API reference](https://www.servicenow.com/docs/access?context=servicenow-fluent-api-reference&version=xanadu&pubname=xanadu-application-development&ft:locale=en-US)」を参照してください。

* アクセス制御リスト (ACL)
* アプリケーションメニュー
* 自動テストフレームワーク (ATF) テスト
* ビジネスルール
* クライアントスクリプト
* リスト
* プロパティ
* レコード
* ロール
* スクリプト済み REST API
* テーブル
{#servicenow-fluent__ul_cx1_db3_zbc}

## 使用法 {#servicenow-fluent__section_dgj_1b3_zbc}

拡張子が .now.ts のファイルで、ServiceNow Fluent API のオブジェクトを使用して、アプリケーションのメタデータを定義します。また、@servicenow/sdk/core からの API に、必要なインポートも含める必要があります。  
次の例には、アプリケーションのテーブル、クライアントスクリプト、およびビジネスルールの定義が含まれています。ビジネスルールは、script.js JavaScript モジュールの関数を使用します。

    import '@servicenow/sdk/global'
    import { BusinessRule } from '@servicenow/sdk/core'
    import { ClientScript } from '@servicenow/sdk/core'
    import { Table, DateColumn, StringColumn } from '@servicenow/sdk/core'
    import { showStateUpdate } from '../server/script.js'

    //creates todo table, with three columns (deadline, status and task)
    export const x_snc_example_to_do = Table({
        name: 'x_snc_example_to_do',
        schema: {
            deadline: DateColumn({ label: 'deadline' }),
            state: StringColumn({
                label: 'State',
                choices: {
                    ready: { label: 'Ready' },
                    completed: { label: 'Completed' },
                    in_progress: { label: 'In Progress' },
                },
            }),
            task: StringColumn({ label: 'Task', maxLength: 120 }),
        },
    })

    //creates a client script that pops up 'Table loaded successfully!!' message everytime todo record is loaded
    ClientScript({
        $id: Now.ID['cs0'],
        name: 'my_client_script',
        table: 'x_snc_example_to_do',
        active: true,
        applies_extended: false,
        global: true,
        ui_type: 'all',
        description: 'Custom client script generated by Now SDK',
        messages: '',
        isolate_script: false,
        type: 'onLoad',
        script: script`function onLoad() {
            g_form.addInfoMessage("Table loaded successfully!!")
        }`,
    })

    //creates a business rule that pops up state change message whenever a todo record is updated
    BusinessRule({
        $id: Now.ID['br0'],
        action: ['update'],
        table: 'x_snc_example_to_do',
        script: showStateUpdate,
        name: 'LogStateChange',
        order: 100,
        when: 'after',
        active: true,
    })

アプリケーションのビルド後、このソースコードはインスタンスで次のアプリケーションメタデータファイルを生成します。
図 : 1. ServiceNow Fluent コードから生成されたアプリケーションメタデータ
**関連情報**   

* [Define application metadata in code with ServiceNow Fluent in the ServiceNow IDE](https://www.servicenow.com/docs/access?context=define-metadata-code-fluent-ide&version=xanadu&pubname=xanadu-application-development&ft:locale=en-US)
* [Define application metadata in code with ServiceNow Fluent and the ServiceNow SDK](https://www.servicenow.com/docs/access?context=define-metadata-code-fluent-sdk&version=xanadu&pubname=xanadu-application-development&ft:locale=en-US)

