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

# System integration

> Foreign keys integration

Often a system integration approach will use the **Number fields** (for example, `Contact.Number1` or `Project.Number`).

If the identifier is too complex or if there are more systems than there are number fields, then the Foreign Key system is worth checking out.

It is more complex than the number fields, but it is much more flexible.

## Example

We have an ERP system that we want to synchronize with SuperOffice.

First, we need to create a foreign key application for the ERP system.

| foreignapp\_id | name        | registered          | registered\_associate\_id |
| -------------- | ----------- | ------------------- | ------------------------- |
| 167            | CRM Mailbox | 28.02.2019 11:27:39 | 1001                      |
| 446            | Handshake   | 24.05.2020 14:36:11 | 2707                      |
| 461            | erp         | 03.05.2021 20:12:02 | 152                       |

* `App_id` = 461
* `name` = "erp"

Then we create a dummy device - since the ERP system does not travel around on mobile phones.

| foreigndevice\_id | name | device\_id | foreignapp\_id | owner\_id | lastsynced |
| ----------------- | ---- | ---------- | -------------- | --------- | ---------- |
| 461               | erp  |            | 461            | 0         |            |

Finally, we add a foreign key entry for the ERP ID for the contact

| foreignkey\_id | foreigndevice\_id | table\_id | record\_id | subkey | subvalue |
| -------------- | ----------------- | --------- | ---------- | ------ | -------- |
| 96734          | 461               | 5         | 56200      | erp-id | 1234     |

We can retrieve the SuperOffice contact ID using the ERP ID 1234 like this:

```SQL theme={null}
SELECT record_id FROM foreignkey
WHERE foreigndevice_id = 461 AND table_id = 5 AND subkey='erp-id' AND subvalue='1234'
```

We can find the ERP ID using the SuperOffice contact ID 56200 like this:

```SQL theme={null}
SELECT subvalue FROM foreignkey
WHERE foreigndevice_id = 461 AND table_id = 5 AND record_id = 56200 AND subkey = 'erp-id'
```


## Related topics

- [Google Workspace document integration](/integrations/g-suite/index.md)
- [SuperOffice integrations](/integrations/index.md)
- [Permissions for SuperOffice Document Library integration (app)](/integrations/sharepoint-documents/permissions-app.md)
- [System requirements for WebTools](/integrations/webtools/system-requirements.md)
- [Integration scenarios (cloud)](/en/online/integrate/index.md)
- [Which user to use](/en/api/authentication/online/which-user-to-use.md)
