> For the complete documentation index, see [llms.txt](https://docs.wem.io/platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wem.io/platform/wemtipsandtricks/working-with-data/using-odata-to-transfer-data-between-runtimes.md).

# Using OData to transfer data between runtimes

So, you’ve been building a nice application and testing it in the Staging Runtime. While doing so, you’ve entered quite some useful data. When it’s time to go Live, you publish and start the Live Runtime of your application. Alas… no data! You will need to re-enter everything… Or maybe not?!

With the support for OData, both consuming and exposing, WEM makes it quite easy to transfer data from one runtime to another for your project. This is particularly useful in two cases:

1. When you go live with your application and want to re-use data which is already available in Staging;
2. When your application has been running Live for some time, containing lots of useful data and you want to get it available in Staging for testing new or changed features or investigate bugs.

So, how do you get this working? Let’s work out number 1:

### Getting data from Staging to Live

#### Create the OData Exposure:

1. Go to the [Security Panel](/platform/wemmodeler/project-settings/security-settings.md) on the [Project Settings](/platform/wemmodeler/project-settings.md) page;
2. Create an OData Login and give it Full Access (or determine which access is really necessary);
3. Publish to Staging, this will enable OData access on the Staging runtime database;

#### Import the OData Service

<div align="left"><img src="/files/z5lAr5hUKjimZ1IjQvKY" alt=""></div>

1. Go to Webservices Tab in the Project tree, access the context menu on \[Remote data sources] and click \[Import OData Service];&#x20;
2. Enter the OData Service information:&#x20;
   * Enter a name for this service (like MyProjectStagingData);
   * Use the portal’s Staging URL, and append `/odata/`, e.g.: `https://portalname.staging.wem.io/odata/`;
   * Enter the credentials of the OData Login created in previous step;
   * Hit Import and see the lists and fields appear in the tree...

#### Then, build flowcharts

Using the remote data source (in this case, your Project Staging Runtime data), the database lists are available directly from your Project Tree (Remote Data Sources) and you can use them the same way as you use the database lists in your Data Model with listnodes on flowcharts, datagrids and repeaters on Templates.

You can drop a Datagrid on a template based on any of the lists in the Remote Data Source just to display the data. You can put a loopnode on such a list and copy the data to the corresponding list in your Data Model (add new row and handle each corresponding field with each iteration of this loop). Run it in preview mode to get the Staging data into Preview.

#### Be careful, use filters and checks where necessary!

Check if you are in the correct runtime, by using the `IsLive()` or `IsStaging()` functions (you don’t want to accidentally copy staging data into staging again…); Check if an item already exists, if you are going to use this flowchart repeatedly; Do not use the ID-fields, as they are automatically generated so they might (and probably will) be different between the Staging and Live runtimes.

**Mind the Concepts**! When copying staging concept fields to live concept fields, the underlying technical information is not exactly the same. Using an Assignment Node on a `Live.DataModel.ConceptField` and plainly assigning it with the `ExternalDataSource.StagingData.DataModel.ConceptField` will just not work as you might expect. But it’s easy to map it correctly with the available Ontology-functions.

For a **Single Select** field, use something like:

```
first(concept of GetChildren(‘root concept of single select’) 
where tostring(concept) = tostring(ExternalDataSource...SingleSelectField))
```

as the expression in the assignment node (*replace the fields and concepts with the correct information*).

For a **Multi Select** field, use something like:

```
GetDescendants(‘root concept of multi select’)
where tostring(concept) 
	in (tostring(concept) of ExternalDataSource...MultiSelectField)
```

{% hint style="info" %}
This approach using OData to transfer data from Staging to Live is just an example.

Other options are using Export/Import nodes with json or xml forms.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wem.io/platform/wemtipsandtricks/working-with-data/using-odata-to-transfer-data-between-runtimes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
