> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Configure data models for InField

> Plan and configure the source data and the Cognite Data Fusion project that will power InField with data modeling.

<Warning>
  The features described in this section are in [public preview](/cdf/product_feature_status#public-preview) and may change.
</Warning>

Proper planning is crucial to setting up InField. This section helps you plan and configure the source data and the Cognite Data Fusion (CDF) project that will power the application and describes how to set up assets and visualize data in InField.
You can also use the [Cognite Toolkit](/cdf/deploy/cdf_toolkit/guides/set_up_infield) to use pre-built configurations to set up InField.

<Note>
  Looking for legacy APM configuration documentation for reference purposes, see [here](/cdf/infield/guides/config).
</Note>

## Before you start

Make sure you have the following:

* A project registered in the [CDF application](https://fusion.cognite.com). It must be a **Data Modeling only** project.
* [The CDF API and the CDF application registered in Microsoft Entra ID](/cdf/access/entra/guides/configure_cdf_azure_oidc) and [Microsoft Entra ID and CDF groups set up to control access to CDF data](/cdf/access/entra/guides/create_groups_oidc).
* Assets in the CDF project populated in the [`CogniteAsset` concept](/cdf/dm/dm_reference/dm_core_data_model#asset) .
* [URLs](/cdf/admin/allowlist) in your allowlist.

<Warning>
  Make sure to [set up locations in InField](#configure-locations) even if you have them set up in CDF. At the moment, CDF and InField use different location concepts.
</Warning>

## Set up access

You can use your existing identity provider (IdP) framework to manage access to InField and choose admin users. We currently support Microsoft Entra ID. By creating groups, you can assign different sets of capabilities to users.

### Create an admin group

Create a group of users who can configure the InField application across all [locations](/cdf/locations/guides). See also how to [configure locations](#configure-locations) in InField.

<Steps>
  <Step title="Navigate to Manage access">
    Go to [<span class="ui-element">CDF</span>](https://fusion.cognite.com) > <span class="ui-element">Manage</span> > <span class="ui-element">Manage access</span>.
  </Step>

  <Step title="Create the group">
    Create a group with the required name `applications-configuration`.
  </Step>

  <Step title="Assign capabilities">
    Give `read` and `write` access to all capabilities with the scope `All`, or have the minimum set of capabilities.
  </Step>
</Steps>

| Capability type      | Action                                          | Scope                             | Description                                               |
| -------------------- | ----------------------------------------------- | --------------------------------- | --------------------------------------------------------- |
| Groups               | `groups: read`, `groups: list`                  | All                               | For InField administrators to grant access to users.      |
| Data models          | `dataModel:read`                                | All                               | View data models.                                         |
| Data model instances | `dataModelInstance:read`                        | All                               | Access data organized in data models.                     |
| Data model instances | `dataModelInstance:write`                       | `cognite_app_data`, `APM_Config`  | Access and edit data organized in data models and spaces. |
| Data model instances | `dataModelInstance:write_properties`            | Spaces with time series instances | Access, create and edit time series data.                 |
| Location filters     | `locationfilters:read`, `locationfilters:write` | All                               | View locations in your InField project.                   |

### Create user groups

Create groups of users who can view checklists, administer checklists and templates, and work with checklists in the field. You can create similar groups for different locations. The groups can have the same capabilities but different access based on the group name.

<Note>
  Group names are suggestions and can differ from user to user.
</Note>

| Name                                    | Description                                                                                                                            |
| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `infield_dev_location_viewers`          | Users in the group can view but not edit checklists in the specified location (`location`) and environment (`dev`).                    |
| `infield_dev_location_checklist_admins` | Users in this group can create, update, delete, and approve checklists in the specified location (`location`) and environment (`dev`). |
| `infield_dev_location_template_admins`  | Users in this group can create, update, and delete templates in the specified location (`location`) and environment (`dev`).           |
| `infield_dev_location_checklist_users`  | Users in this group can work with checklists and create observations in the specified location (`location`) and environment (`dev`).   |

Assign the following group capabilities:

| Capability type      | Action                               | Scope                                                                                                                                                                                                                                                  | Description                                               |
| -------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------- |
| Groups               | `groups:read`, `groups: list`        | All                                                                                                                                                                                                                                                    | View user groups.                                         |
| Data models          | `dataModel:read`                     | `cdf_cdm` , `cdf_idm`, `APM_Config, cdf_infield, cdf_apps_shared , idm_customer_datamodel_space`- where you can extend the views if necessary                                                                                                          | View and analyze the data created in InField.             |
| Data model instances | `dataModelInstance:read`             | `APM_Config, cognite_app_data, location_app_data_space, location_source_data_space` - a list of spaces to read the data from; `cdf_cdm_units` - a space to use units for time series. Add all such spaces you want to read the data from to the scope. | View and analyze the data created in InField.             |
| Data model instances | `dataModelInstance:write`            | `cognite_app_data`                                                                                                                                                                                                                                     | Access and edit data organized in data models and spaces. |
| Data model instances | `dataModelInstance:write_properties` | Spaces with time series instances                                                                                                                                                                                                                      | Access, create and edit time series data.                 |
| Location filters     | `locationfilters:read`               | All                                                                                                                                                                                                                                                    | View locations in InField.                                |

## Create data modeling spaces

InField stores asset data in [data models](/cdf/dm). You need to create at least 4 spaces to store your data and data models.

| Space name                     | Description                                                                                                                                                           |
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cognite_app_data`             | This space holds user data, such as user profiles.                                                                                                                    |
| `APM_Config`                   | This space holds configurations in Asset Performance Management (APM).                                                                                                |
| `yourRootLocation_source_data` | This space holds data from your source systems (like SAP) for one root location. Replace `yourRootLocation` with the name of your root location/asset.                |
| `yourRootLocation_app_data`    | This space holds data created in InField (like checklists and templates) for one root location. Replace `yourRootLocation` with the name of your root location/asset. |
| `ApmAppData`                   | You don't need to set up or change this space. `ApmAppData` is a system data model that's present in all projects by default. The data model has the `System` tag.    |

<Note>
  Create a unique pair of `_source_data` and `_app_data` spaces for **each** root location you want to configure in InField. For example, if you have two root locations named `plant-a` and `plant-b`, you will need to create four spaces in total:

  * `plant-a_source_data`
  * `plant-a_app_data`
  * `plant-b_source_data`
  * `plant-b_app_data`
</Note>

You can create spaces in the following ways:

* With the [Cognite Python SDK](#spaces-created-with-sdk).
* With the [Cognite API](#spaces-created-with-api).
* 2 location spaces directly in [InField](#spaces-created-in-infield).

### Spaces created with SDK

You can create the spaces using [Cognite Python SDK](https://cognite-sdk-python.readthedocs-hosted.com/en/latest/index.html). Use the following Python code and replace `yourRootLocation` with your root location/asset name in `yourRootLocation_source_data`, `yourRootLocation_app_data`.

<Accordion title="Create spaces">
  ```python theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}

  from cognite.client.data_classes.data_modeling import SpaceApply

  # List of spaces to create
  spaces_to_create = ["yourRootLocation_source_data", "yourRootLocation_app_data", "APM_Config", "cognite_app_data"]

  # Apply spaces
  for space_name in spaces_to_create:
   client.data_modeling.spaces.apply(SpaceApply(space=space_name))

  ```
</Accordion>

### Spaces created with API

You can create the spaces using the [API endpoint](/api-reference/concepts/20230101/spaces):

* `cognite_app_data`
* `APM_Config`
* `yourRootLocation_source_data`
* `yourRootLocation_app_data`

Use the same names for the `space` and `name` attributes. The `space` attribute is also the space ID.
Replace `yourRootLocation` with your root location/asset name in `yourRootLocation_source_data`, `yourRootLocation_app_data`.

`APM_Config` is the space that you can create manually in CDF or automatically by running the script. You create this space by creating corresponding data model.

### Spaces created in InField

To create location spaces in InField:

<Steps>
  <Step title="Navigate to location settings">
    Sign in to InField and select ⚙ > location to which you want to add spaces.
  </Step>

  <Step title="Add customer instance space">
    On the <span class="ui-element">Customer instance spaces</span> tab, select the space from the list or enter the name of the space, for example, `yourRootLocation_source_data` and press <kbd>Enter</kbd>.
  </Step>

  <Step title="Add InField instance space">
    On the <span class="ui-element">InField instance spaces</span> tab, select the space from the list or enter the name of the space, for example, `yourRootLocation_app_data` and press <kbd>Enter</kbd>.
  </Step>
</Steps>

## Configure locations

<Tip>
  Users need admin rights to configure locations.
</Tip>

The <span class="ui-element">Locations</span> page lists your root locations. Root location is a root asset that's at the top of the asset hierarchy. The root asset is a digital representation of a site, such as an oil platform, a plant, or an installation. Each site in InField should have a root location. For each location you want to be available in InField, complete the configuration in the InField application.

<Steps>
  <Step title="Add location">
    Sign in to [InField](https://cognite-infield.cogniteapp.com), select (⚙) > <span class="ui-element">+ Add location</span>.
  </Step>

  <Step title="Name and describe">
    Enter the name and the description and select <span class="ui-element">Add</span>.
  </Step>

  <Step title="Complete configuration">
    Select the location to complete configuration.
  </Step>
</Steps>

### Location details

Update the name and description of your location.

### View mappings

[Views](/cdf/dm/dm_concepts#view) contain a group of properties that you can change for specific cases. By default, InField uses the Cognite process industries data model that extends the core data model to meet the needs of the process industries. You can customize entity definitions (or views), such as `CogniteAsset` and `CogniteMaintenanceOrder` by extending them with properties that are specific to your operations. For example, to extend the `CogniteMaintenanceOrder` property, you can create a new view and add the `Cost` field to this property.

In InField, you can select the entities you want to use, such as activities, assets, etc., with views defined in the `cdf_idm` ([Process industries data model](/cdf/dm/dm_reference/dm_process_industry_data_model)), `cdf_cdm` ([Core data model](/cdf/dm/dm_reference/dm_core_data_model)) spaces, or the space where you store your custom views.

| Data entity                          | View                                     | Extendable |
| ------------------------------------ | ---------------------------------------- | ---------- |
| Asset                                | cdf\_cdm.CogniteAsset                    | Yes        |
| Activity (work orders)               | cdf\_idm.CogniteMaintenanceOrder         | Yes        |
| Operations                           | cdf\_idm.CogniteOperations               | Yes        |
| Notifications                        | cdf\_idm.CogniteNotification             | Yes        |
| Files (P\&IDs)                       | cdf\_cdm.CogniteFile                     | No         |
| Annotations (file Contextualization) | cdf\_cdm.CogniteDiagramAnnotation (edge) | No         |
| 3D                                   | Ingested through 3D APIs                 | No         |

To configure the views you want to use:

<Steps>
  <Step title="Navigate to View mappings">
    Go to <span class="ui-element">Locations</span> > <span class="ui-element">View mappings</span>.
  </Step>

  <Step title="Select spaces for properties">
    For each property, select either the default space or the space where you created custom views. In the current implementation, you can configure view mappings of 4 entities only.
  </Step>

  <Step title="Save changes">
    Save to apply the changes.
  </Step>
</Steps>

<Warning>
  Make sure the view version always matches the data model version. Otherwise, the table on the Overview page won't work correctly.
</Warning>

Each entity type, such as activity, asset, etc., has a standard view defined in the `cdf_idm` system space. To view and customize views, go to [**CDF**](https://fusion.cognite.com) > **Data fusion** > **Data models** > find and select **CogniteProcessIndustries**.

### Customer instance space

Select the space to store data on assets, work orders, notifications, and other data coming from a customer source system, such as SAP, for a particular location. Currently, you can select only one space.

### InField instance space

Select the space to store data on templates, checklists, and observations created in the application for a particular location.

### Observations

Configure observations to allow field workers to report issues and track maintenance needs. Observations are now fully supported on IDM (Industrial Data Model) projects.

To enable and configure observations:

<Steps>
  <Step title="Navigate to Features">
    Go to <span class="ui-element">Application configuration</span> <icon name="settings" /> select your location > <span class="ui-element">Features</span>.
  </Step>

  <Step title="Enable observations">
    Enable the <span class="ui-element">Observations</span> feature.
  </Step>

  <Step title="Configure observation form fields">
    Configure observation form fields to collect relevant information:

    * **Asset hierarchy search** — enabled by default, allows users to search and select assets from the asset hierarchy when creating observations.
    * **Assignment** — configure which user groups or disciplines can be assigned observations.
    * **Due dates** — enable due date tracking for observations to ensure timely follow-up.
  </Step>

  <Step title="Optional. Configure SAP writeback">
    Configure SAP writeback to send completed observations to SAP as notifications.
  </Step>
</Steps>

<Info>
  Observations created in InField are stored in the `location_app_data_space` for the current location and can be queried using the data model APIs.
</Info>

### Asset explorer

To display related data, such as work orders, time series, and documents on the **Asset explorer** page, ensure these data objects are connected to the corresponding assets in Cognite Data Fusion. InField uses these relationships to find and display the relevant information for each asset.

| Data object          | Requirements                                                                                                                                                                                                                                                                                                       |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 3D                   | The `CogniteAsset.object3D` property needs to have a 3D model linked to the asset in the `source_instance_space`.                                                                                                                                                                                                  |
| Trends (time series) | The `CogniteTimeSeries.assets` property needs to have a direct relation to the asset in either the `app_instance_space` or `source_instance_space` of the current location.                                                                                                                                        |
| Documents            | The `CogniteFile.assets` property needs to have a direct relation to the asset in either the `app_instance_space` or `source_instance_space` of the current location. Supported document types in `CogniteFile.mimeType` include 'text/plain', 'text/csv', 'application/json', 'application/pdf', 'image/svg+xml'. |
| Work orders          | The `CogniteMaintenanceOrder.mainAsset` property needs to have a direct relation to the asset in the `source_instance_space` of the current location.                                                                                                                                                              |
| Notifications        | The `CogniteNotification.asset` property needs to have a direct relation to the asset in the `source_instance_space` of the current location.                                                                                                                                                                      |
| Properties           | The `CogniteAsset` view needs to be extended with any custom properties you want to display for the asset.                                                                                                                                                                                                         |
| Media                | The `CogniteFile.assets` property needs to have a direct relation to the asset in either the `app_instance_space` or `source_instance_space`. Supported file types in `CogniteFile.mimeType` include 'video/quicktime', 'video/mp4', 'image/jpeg', and 'image/png'.                                                |

<Tip>
  Make sure to contextualize files to the relevant asset to see them on the asset's card.
</Tip>

To test the location you just configured:

<Steps>
  <Step title="Navigate to Select location">
    In the top right, select your profile > **Manage account** > **Select location**.
  </Step>

  <Step title="Select the new location">
    From the list, select the location you just created.
  </Step>
</Steps>

Once the application reloads, you can work in your new location.
