---
sourceDocument: Australia Build or modify applications
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/pt-BR/application-development

 Release :

    - australia

ft:locale :

    - pt-BR

ft:publication_title :

    - Australia Build or modify applications

ft:clusterId :

    - cadev

bundleId :

    - cadev

workflow :

    - Development, Data, and Analytics


---

# 3. Define a table in ServiceNow Fluent code

# Tutorial part 3: Define a table in ServiceNow Fluent code {#ariaid-title1}

* Versão de lançamento: Australia
* 
* Atualizado 12 de mar. de 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 5 min. de leitura

Create a table and reference it in sample script definitions using the ServiceNow Fluent APIs.

## Antes de Iniciar

Complete [Tutorial part 2: Initialize a repository for your application](https://servicenow-prod.fluidtopics.net/ejWzmXx0OStAxpl88jC8Xw "Initialize a local Git repository for an application in the ServiceNow IDE and push it to a remote Git repository in GitHub to manage the application in source control.").

Role required: admin

## Por Que e Quando Desempenhar Esta Tarefa


ServiceNow Fluent is a domain-specific language (DSL) based on TypeScript for defining the metadata files \[sys_metadata\] that make up applications and includes APIs for the different types of metadata, such as tables, roles, ACLs, business rules, and Automated Test Framework tests. You use objects in the ServiceNow Fluent APIs to define metadata in files with the .now.ts extension. The ServiceNow IDE has language processing and validation for ServiceNow Fluent APIs and applications by default. For more information about ServiceNow Fluent, see [ServiceNow Fluent](https://servicenow-prod.fluidtopics.net/pP6OxbNArnr2tlBRkmrTfw "Define application metadata in source code using the ServiceNow Fluent domain-specific programming language.").

In this example, you create a simple table for a to-do list using objects in the ServiceNow Fluent Table API. Then, you update the sample code for business rule and client script definitions to reference the new table. Lastly, you review your changes from the File Categories viewMetadata Explorer. For more information about the Table API, see [Table API - ServiceNow Fluent](https://servicenow-prod.fluidtopics.net/gA9bvW9UJg_DACsQbJgZhA#table-api-now-ts "The Table API defines tables [sys_db_object] to store data in an application.").

## Procedimento

1. From the Activity Bar, select the File Explorer view (![File Explorer]()).
2. Navigate to the src/fluent directory in your application.
3. Open the index.now.ts sample file.  
   Dica:  
   You can write ServiceNow Fluent code in a single file or as many .now.ts files as you want and organize files in directories within the fluent directory.
4. On a new line at the end of the file, enter <kbd class="ph userinput">Table({})</kbd> to add the Table object.
5. From the Status Bar, select the diagnostics icon (![Diagnostics]()) to open the Problems panel and check for issues in the code.  
6. Right-click the error that appears and select the Update import from "@servicenow/sdk/core" quick fix.  
   In line 2, the Table object is added to the list of imports from @servicenow/sdk/core:

       import { BusinessRule, ClientScript, Table } from '@servicenow/sdk/core'

   Dica:  
   After fixing this issue, you can close the Problems panel while you proceed through the following steps. In a later step, you return to it if any issues remain.
7. In the Table object, add the following properties.  
   * name: The table name must begin with the application scope and use all lowercase letters in the following format: <kbd class="ph userinput">&lt;scope&gt;_&lt;name&gt;</kbd>. You can find the scope in the now.config.json file for the application.
   * label: The label should be unique and appears for the table in list and form views.
   * extends: The name of another table on which the table is based.
   {#tutorial-define-table-fluent-ide__ul_k4f_mz4_32c}

       Table({
           name: 'x_snc_hello_world_to_do', //ensure that the name begins with the correct scope (<scope>_<name>)
           label: 'To-do Items',
           extends: 'task',
       })

   Dica:  
   Hover over an object to see its in-product documentation.

8. For type-ahead support when defining columns in the table, before the Table object, add an exported variable with the same name as the name property.  

       export const x_snc_hello_world_to_do = Table({
           name: 'x_snc_hello_world_to_do',
           label: 'To-do Items',
           extends: 'task',
       })

9. In the Table object, add the schema property to define columns in the table.  

       export const x_snc_hello_world_to_do = Table({
           name: 'x_snc_hello_world_to_do',
           label: 'To-do Items',
           extends: 'task',
           schema: {
               //define columns here
           }
       })

   The schema property is an array of Column objects. There are many types of columns based on the field type. Column objects use the format \<Type\>Column where
   <var class="keyword varname">&lt;Type&gt;</var> is the field type.

   Use the following details to define three columns in the table: Deadline, Matrix, and Task. Refer to the [Column object](https://servicenow-prod.fluidtopics.net/gA9bvW9UJg_DACsQbJgZhA#column-object-now-ts "Add a column [sys_dictionary] to a table.") documentation to help you configure each column.
   {#tutorial-define-table-fluent-ide__table_b33_tq4_32c__entry__2}

   | Column name | Details |
   |-|-|
   | deadline | * Label: Deadline * Type: Date/Time {#tutorial-define-table-fluent-ide__ul_w4g_4r4_32c} |
   | matrix | * Label: Matrix * Type: String * Choices: * Label: Urgent and Important * Label: Important but Not Urgent * Label: Urgent but Not Important * Label: Neither Urgent nor Important {#tutorial-define-table-fluent-ide__ul_bty_gy4_32c} {#tutorial-define-table-fluent-ide__ul_og4_sr4_32c} |
   | task | * Label: Task * Type: String * Max length: 120 {#tutorial-define-table-fluent-ide__ul_g3h_5r4_32c} |
   [ ]

   {#tutorial-define-table-fluent-ide__table_b33_tq4_32c}  
   With these details, the schema property should look similar to this example. The keys that you use for the choices can be any string.

       export const x_snc_hello_world_to_do = Table({
           name: 'x_snc_hello_world_to_do',
           label: 'To-do Items',
           extends: 'task',
           schema: {
               deadline: DateColumn({ label: 'Deadline' }),
               matrix: StringColumn({
                   label: 'Matrix',
                   choices: {
                       do: { label: 'Urgent and Important' },
                       decide: { label: 'Important but Not Urgent' },
                       delegate: { label: 'Urgent but Not Important' },
                       delete: { label: 'Neither Urgent nor Important' },
                   },
               }),
               task: StringColumn({ label: 'Task', maxLength: 120 }),
           },
       })

10. In line 2, add imports for the DateColumn and StringColumn objects.  

        import { BusinessRule, ClientScript, Table, DateColumn, StringColumn } from '@servicenow/sdk/core'

11. Update the existing business rule and client script definitions to reference the table you created.
    1. In the ClientScript object, change the value of the table property to the table name (<kbd class="ph userinput">x_snc_hello_world_to_do</kbd>).
    2. Repeat the previous step for the BusinessRule object.
    {#tutorial-define-table-fluent-ide__substeps_hvw_lmc_j2c}
12. If the diagnostics icon (![Diagnostics]()) shows any errors or warnings, select it to open the Problems panel and review the diagnostic messages and quick fixes to resolve them.
13. Save your changes using one of the following keyboard shortcuts.  
    * Windows: Ctrl-S
    * Mac: Cmd-S

    {#tutorial-define-table-fluent-ide__ul_u1h_sy4_32c}  
    Nota:  
    If you have unsaved changes in a file, a dot icon appears on the file tab.
14. From the Status Bar, select Build and InstallBuild and Deploy.  
    If the deploymentinstallation completes successfully, the updated ServiceNow Fluent source code is compiled into Application Files \[sys_metadata\] on the instance.
15. Review your changes as metadata.
    1. From the Activity Bar, select the File CategoriesMetadata Explorer view(![Metadata Explorer]()).
    2. Select your application to expand it.
    3. Navigate to DataTable and select To-do Items.  
       The table opens in Table Builder.

    {#tutorial-define-table-fluent-ide__substeps_kck_k2d_j2c}
16. **Opcional:** Edit the metadata and synchronize your changes into the source code.  
    From the File Categories viewMetadata Explorer, you can simulate another user editing the metadata outside of the source code to see changes transformed back into the code you added.
    1. In Table Builder, search for the Task field and change the Column label from "Task" to "To Do".
    2. Select Save.
    3. From the Activity Bar, select the Now SDK view (![Now SDK]()).
    4. Select Sync Changes.  
       In the index.now.ts file, you should see the label property of the task column changed to `'To
       Do'`.

           task: StringColumn({ label: 'To Do', maxLength: 120 }),

    {#tutorial-define-table-fluent-ide__substeps_kh3_bv2_t2c}

## Resultado

You have created your first application metadata using ServiceNow Fluent APIs. The To-do Items \[x_snc_hello_world_to_do\] table can be modified in source code by other ServiceNow IDE users or from other ServiceNow AI Platform user interfaces.

From the ServiceNow AI Platform, you can navigate to the list view of the table by entering <kbd class="ph userinput">x_snc_hello_world_to_do.list</kbd> in the navigation filter. Because you updated the client script definition to run on
the To-do Items \[x_snc_hello_world_to_do\] table, if you select New to add a record to the table, the message from the client script appears when the record loads.

## O que Fazer Depois

Continue to [Tutorial part 4: Install and use a third-party library](https://servicenow-prod.fluidtopics.net/S156fHAhZWOYwFE4fgkK6g "Install a third-party library from Node Package Manager (npm) and use it in a JavaScript module.").

