> For the complete documentation index, see [llms.txt](https://servicenow-lf.gitbook.io/the-workflow-data-fabric-loom/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://servicenow-lf.gitbook.io/the-workflow-data-fabric-loom/main-exercises/lab-exercise-fundamentals.md).

# Lab Exercise: Fundamentals

[Take me back to main page](/the-workflow-data-fabric-loom/readme.md)

This lab will walk you through creation of the scoped tables needed to interact with the external system integrations.

## Data flow

The data flow below shows how ServiceNow will consume REST API endpoints via Integration Hub Spokes then further processed by a Flow so the entries will be written in the scoped table.

{% @mermaid/diagram content="graph LR
subgraph "ServiceNow AI Platform"
subgraph "Data Integration Layer"
IntHub\[Integration Hub<br/>Spoke/Flow]
end

```
    subgraph "ServiceNow Native Tables"
        ExpenseTable[(Expense Event<br/>Line Items<br/>Scoped Table)]
    end
end

subgraph "External Systems"
    ExpenseAPI[Expense Event<br/>API]
end

%% Data Flow Connections
ExpenseAPI -->|Real-time Events| IntHub
IntHub -->|Write| ExpenseTable

%% Styling
classDef external fill:#2196F3,stroke:#1565C0,stroke-width:2px,color:#fff
classDef platform fill:#4CAF50,stroke:#2E7D32,stroke-width:2px,color:#fff
classDef wdf fill:#9C27B0,stroke:#6A1B9A,stroke-width:2px,color:#fff

class IntHub wdf
class ExpenseTable platform
class ExpenseAPI external" %}
```

> **Color Legend:** 🟣 Workflow Data Fabric | 🟢 Platform | 🔵 External Systems

> [📊 View High-Resolution Diagram](https://raw.githubusercontent.com/leojacinto/WorkflowDataFabric-TypeA/main/.gitbook/assets/dataflow_fundamentals.png)

## Lab story

While you have the power of CMDB at your fingertips, the process we are solving for here does not concern CI data. You will need to create a scoped table which will store information from an expense event API. This can come from cloud services such as AWS or Azure.

The table you will create here will not be used for the rest of the steps and serves mainly to introduce how target tables for REST API endpoints are created for ServiceNow.

## Steps

### Preparation: AI Search configuration

This configuration section includes setting up of AI Search which is a critical tool for the AI Agents for your newly provisioned lab instance.

1. Using an private/incognito browser window, log on to your instance as:

   1. User: **aislab.admin**
   2. Password: **aislab.admin**

   <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-6a487d2510be8a649e662b048f1527b9c84eb8ac%2Fimage%20(1)%20(1).png?alt=media" alt="" width="362"><figcaption></figcaption></figure>
2. Navigate to **All** > <mark style="color:green;">**a.)**</mark> type **Repair Machine Learning Settings** > <mark style="color:green;">**b.)**</mark> click on **Repair Machine Learning Settings**.

   <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2F9VEyWWeOLa9n9cP4D7gH%2Fimage.png?alt=media&amp;token=cf7ec19e-9c59-410e-a12c-0d0721d21b6c" alt=""><figcaption></figcaption></figure>
3. Click on **Reset Machine Learning Settings**.

   <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-e68da72f949bfbf4db567e4dbe652a74da47b8e9%2Fimage%20(2)%20(1).png?alt=media" alt="" width="375"><figcaption></figcaption></figure>
4. You will get a message that the machine learning settings are being reset.

   <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-d71feb07babf1110fa40f2a110e2e6c10292f4a1%2Fimage%20(3)%20(1).png?alt=media" alt="" width="375"><figcaption></figcaption></figure>
5. After a 2-3 minutes, you will get a notification that the machine learning settings are reset. This will do indexing of tables in the background which will be needed for the search functionality to be used by the AI Agents later.

   <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-0c13743e8430a88861a43e85a5530a5f2f366d55%2Fimage%20(5)%20(1).png?alt=media" alt="" width="279"><figcaption></figcaption></figure>
6. Exit your aislab.admin session and go back to your main session where you have logged in as **admin** user with the password provided to you.

### Hands on: Create a Scope

Create a dummy scope. This activity is meant to make you familiar with scope creation, the scope you will create here will not be used in the lab. If you are familiar with scope creation, you can skip this exercise as this is not a dependency in the exercises.

1. Go to the top right portion of your navigation and click on the <mark style="color:green;">**a.)**</mark> **globe icon** then **arrow** **>** the <mark style="color:green;">**b.)**</mark> **list icon** to create new scope.

<figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-36b46f9457f6b092740a6e7bb4b44808ad24ea26%2Fsc_fund_scope_change.png?alt=media" alt="" width="375"><figcaption></figcaption></figure>

2. In the succeeding screen, click **New**.

   <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-7d968c32dac888ca608d34174708e84922dd287e%2Fsc_fund_new_scope.png?alt=media" alt="" width="360"><figcaption></figcaption></figure>
3. Go to section **Start from Scratch** and click **Create**

   <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-62e3a6ee2f40d6686aaf1dac17a17271a1dd76df%2Fsc_fund_create_scope.png?alt=media" alt=""><figcaption></figcaption></figure>
4. Provide the scope details with <mark style="color:green;">**a.)**</mark> name <mark style="color:red;">**Lab**</mark> **Forecast Variance \<YOUR INITIALS>** and the <mark style="color:green;">**b.)**</mark> scope. Click <mark style="color:green;">**c.)**</mark> Create. Note that the scope is a technical name and is automatically populated but you have the option to change it. In this example, the scope is **x\_snc\_forecast\_var**. Feel free to add your initials at the end of the scope. The scope here will not be used in the exercise and is only meant to serve as guide in demonstrating the fundamental steps. Click **Back to list** once done.

   <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-dd63e612ba287f2c8fa09e33dec13ebaef2b0aee%2Fsc_fund_scope_details%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>
5. Verify that you are in the correct scope after you have created it. Being in the correct scope as you proceed with the lab will avoid scope access and object management issues. Do this by a.) clicking on the <mark style="color:green;">**a.)**</mark> scope (globe icon) and ensuring that has the value of the <mark style="color:green;">**b.)**</mark> **Forecast Variance \<YOUR INITIALS>** label you created.

   <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-6f409bb5477f665471107427f68323d8360dd064%2Fsc_fund_dummy_scope.png?alt=media" alt=""><figcaption></figcaption></figure>
6. <mark style="color:red;">**THIS NEXT STEP IS CRITICAL**</mark> to ensure you are working in the correct scope in which the objects for this lab are linked to. You will need to change scope after you have created the simulation scope. Click on the <mark style="color:green;">**a.)**</mark> **scope** (globe icon) and <mark style="color:green;">**b.)**</mark> **Forecast Variance**, this time <mark style="color:red;">**WITHOUT**</mark> your initials. This will be the scope you will use throughout the lab.

   <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-339552250d71779ce354ecdf7875aeb53adf99ab%2Fsc_fund_exercise_scope.png?alt=media" alt=""><figcaption></figcaption></figure>
7. Now that you are in the right scope, you are ready to create the scoped table. Navigate to All > <mark style="color:green;">**a.)**</mark> type **System Definition** > <mark style="color:green;">**b.)**</mark> search for **Tables**

   <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-2d491bc442ef3a88850ea6566c7b2ab234f1a7cd%2Fimage%20(71).png?alt=media" alt=""><figcaption></figcaption></figure>
8. Go to the top right section of the navigation and click **New**.

   <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-b90feb7eff3b62845b08e1e7f480080af45ec0db%2Fsc_fund_new_table.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>
9. Provide the <mark style="color:green;">**a.)**</mark> **Label** as **Expense Transaction Event \<your initials>**. The <mark style="color:green;">**b.)**</mark> **Name** which is a technical identifier will automatically be populated and can be modified to suit your requirement. Finally, <mark style="color:green;">**c.)**</mark> **untick Create module**.

   <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-d67cb149c03bbffa20646561e2f9f7ae5dc2dbeb%2Fsc_fund_new_table_details.png?alt=media" alt=""><figcaption></figcaption></figure>
10. Right click on the header and click **Save**.

    <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-4a0f6414ca42d6f27cca59fc555e521445344264%2Fsc_fund_save.png?alt=media" alt="" width="135"><figcaption></figcaption></figure>
11. Staying in the same screen, an option to create fields for the table will be available. In the tab **Columns** click on **New**.

    <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-09d228d973a9cb7f25db32dd8b0d2de5308c2ada%2Fsc_fund_new_field.png?alt=media" alt=""><figcaption></figcaption></figure>
12. Let us use one column as an example. Provide the <mark style="color:green;">**a.)**</mark> **Type**, in this case **String**. Provide the <mark style="color:green;">**b.)**</mark> **Column label**, in this example, **Cost Center** which will automatically populate the <mark style="color:green;">**c.)**</mark> **Column name**. Since this is the string, provide the <mark style="color:green;">**d.)**</mark> **Max length** of **40**. Finally, right click on then header and <mark style="color:green;">**e.)**</mark> **Save**.

    <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-8a406b6cbc558e3a973867cec5a0d78b6d5d786e%2Fsc_fund_field_details.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>
13. Do the same steps for all of the 16 other fields below. Note that the **Column label**, **Column name**, **Type**, **Max length** vary across some columns. For now, keep **Display** as **false** across all fields. Notice that these 16 fields are expense, invoice, or finance related, specifically tied to the business process problem we are solving for. Correct data foundations are critical to ensure that agents have the correct context and structure especially when delivering enterprise use cases.

    <figure><img src="https://623113061-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPQvQ60HFhWXWnmbX6yJi%2Fuploads%2Fgit-blob-3af2207460524bb004988f0367d07f6ceb8f900b%2Fsc_fund_all_fields.png?alt=media" alt=""><figcaption></figcaption></figure>

## Conclusion

Congratulations! You have created the destination table within ServiceNow for the external REST API sources. As a recap, the table you created will **NOT** be used for the rest of the steps and serves mainly to introduce how target tables for REST API endpoints are created for ServiceNow.

## Next step

Let us continue building the data foundations for the use case. Next up is creation of the Data Fabric tables which will be used by AI Agents. Let us work on AI Agents' ability to use REST API connectivity by proceeding with the [Integration Hub configuration](https://servicenow-lf.gitbook.io/the-workflow-data-fabric-loom/main-exercises/lab-exercise-integration-hub).

[Take me back to main page](/the-workflow-data-fabric-loom/readme.md)
