---
title: "Configuring an Integration with Twinfield"
canonical: "https://help.fieldbuddy.com/space/FBDOCS/2078311112/Configuring%20an%20Integration%20with%20Twinfield"
format: markdown
---
This chapter is a step-by-step explanation of how to configure an Integration for Twinfield. At the end of this chapter you'll have successfully created an Integration, scheduled the Inbound Data Sync and created an Object Mapping for in- and outbound.

# **Authentication**

Authentication is necessary in order to transfer data with the Twinfield platform. In order to authenticate you require a Twinfield account including API-permissions.

> ❌ **Before starting**
> ❌ 
> ❌ Before starting authentication, please, ensure that you are logged in only Salesforce environment and not in any Twinfield environment.


Steps

> Macro (legacy-content)


You are now successfully authenticated with **Twinfield**, and should be able to create sync mappings for both inbound and outbound sync. If there are multiple users authorized, then based on who executes that action, corresponding one will be picked (who caused record update or clicked Inbound Sync).

# **Required fields on SObjects**

If an object is used in an Object Mapping, it requires a few fields. The object you create the fields on depends on the object mapping. For example, if your sync sends data from Account in Connect the field should be created on Account. There's a difference in how to add fields in Salesforce to add Standard or a custom object. Standard objects are: Account, Contact, Opportunity etc. and do not contain the postfix: '__c'. Custom Objects, created by users or other applications have a postfix '__c'. For example: FIELDBUDDY__Work_Order__c.

### Opening up the object

1. In case of a standard object, for example Account. Go to SETUP > Accounts > Fields. This page will show all standard and custom fields on the Account object. Scroll down and click 'New'.
2. In case of a custom object, for example Work Order. Go to SETUP -> Create > Objects. This page will show all the custom objects. Click on the object. This page will show all standard and custom fields on the object. Scroll down and click 'New'.

### Creating custom fields

1. Clicking the 'New' button should open up the 'New Custom Field' wizard. Select the option 'Text' and click 'Next'. The field should be created on the object of which you want to send data from. This depends on your Object Mapping.  
> Macro (inline-media-image)
2. The second step of the wizard will be shown. Use the following input and click 'Next'.
  1. Field Label: External Id
  2. Length: 255
  3. Field Name: External_Id
  4. Description: In this field the external id from Twinfield is stored. This field is being used by FieldBuddy Connect.
  5. Unique: True
  6. External ID: True  
> Macro (inline-media-image)
3. In the third step all profiles are shown. Make sure you set Visible to 'True' and Read-Only to 'False' to any profile that will importing or exporting data.
  
4. In the fourth step of the wizard all page-layouts are shown. Adding the field to an layout is optional and not required.
  
5. Click Save & New. This will restart the wizard.
6. Select 'Checkbox' and click 'Next'. Use the following input and click 'Next'.
  1. Field Label: Is Synced
  2. Default value: unchecked
  3. Field Name: Is_Synced
  4. Description: If this field is set to true, the record is synchronized with Twinfield. This field is being used by FieldBuddy Connect.  
> Macro (inline-media-image)
7. In the third step all profiles are shown. Make sure you set Visible to 'True' and Read-Only to 'False' to any profile that will importing or exporting data.
8. In the fourth step of the wizard all page-layouts are shown. Adding the field to an layout is optional and not required.
9. Click Save & New. This will restart the wizard.
10. Select 'Date/Time' and click 'Next'. Use the following input and click 'Next'.
  1. Field Label: Last Sync
  2. Field Name: Last_Sync
  3. Description: In this field the date and time is stored when the record last successfully synchronized with Twinfield. This field is being used by FieldBuddy Connect  
> Macro (inline-media-image)
11. In the third step all profiles are shown. Make sure you set Visible to 'True' and Read-Only to 'False' to any profile that will importing or exporting data.
12. In the fourth step of the wizard all page-layouts are shown. Adding the field to an layout is optional and not required.
13. Click Save

You are done creating fields for this object. Creating these fields are required for each object. This object can now be used in an Object Mapping.

# **Object Mappings for the Inbound Data Sync**

The Inbound Data Sync retrieves all data from the external system according to the Object Mapping configuration. In the following chapters a few example configurations will be created in a step-by-step process.

### Importing Accounts

In this example FlexConnect will be importing Accounts from Twinfield  into the standard Accounts object in Salesforce.

Here and below, lookup to Service Provider should be specified.

> ℹ️ Make sure to have test data available in Twinfield.

> ❌ If you start an import, make sure to have enough data space in your organisation.

#### <span style="color: #000000">Steps - Creating the Object Mapping</span>

<span style="color: #000000">To get data from Twinfield, we need to create several mappings.</span>

<span style="color: #000000">The first (LIST) mapping is needed to get a list of identifiers for all existing records.</span>

<span style="color: #000000">The second (DETAILS) mapping is needed to obtain detailed information for each identifier.</span>

<span style="color: #000000">Also, if the object contains an array of child objects (for example, several addresses related to the same account), then to create addresses a CHILD mapping should be created.</span>


<span style="color: #000000">**List object mapping**</span>

1. Go to the Page 'Object Mapping'.
2. Click the button '**New**', select '**Twinfield'** recordtype and and fill in the following data.
  ***** Field **Filter criteria** contains the office code (NLA000XXX). This code can be found after authorization in Twinfield.  
> Macro (inline-media-image)

  
  
Other values are shown in the screenshot below.
  More information about other search criteria can be found in the [**official documentation**](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Miscellaneous/Finder).


<span style="color: #000000">**Details object mapping**</span>

1. Go to the Page 'Object Mapping'.
2. Click the button '**New**', select '**Twinfield'** recordtype and and fill in the following data.

![image](media://b550e4b8-4b58-4348-9dbc-676cd8cf18de)

| **Field** | **Data** |
| --- | --- |
| Endpoint URL | /processxml.asmx |
| Execution Order***** | 2 |
| External Id field******* | dimension.code |
| External Object******* | dimension |
| Internal field for external Id | External_Id__c |
| Internal Object | Account |
| Is Active | True |
| Filter criteria****** | <type>dimensions</type><office>NLA000XXX</office><dimtype>DEB</dimtype><code>[*]</code> |
| Last Sync Datetime API | Last_Sync__c |
| Object Mapping Name | 02 I Customer => Account (Details) |
| Operation Type | Upsert |
| Parent Object Mapping | - |
| Service Provider | <your service provider name> |
| Sync Direction | Inbound |

|  |  |
| --- | --- |
| ![image]() | ![image]() |

  
***** Details.ExecutionOrder **must be** List.ExecutionOrder + 1.  
****** Field **Filter criteria** contains the office code (NLA000XXX). This code can be found in the same way as in the previous example.  


> ℹ️ Node **<code>[*]</code>** is required and should only contain the value **[*]**.

|  |  |
| --- | --- |
| ![image]() | ![image](media://764803b8-7351-40fe-bae3-a3872322c5ee) |


  
**Child object mapping**

1. Go to the Page 'Object Mapping'.
2. Click the button '**New**', select '**Twinfield'** recordtype and and fill in the following data.

![image](media://a6d508be-6748-4727-b38c-a12d43c353bd)

| **Field** | **Data** |
| --- | --- |
| External Id field*** | address[id] |
| External Object** | addresses |
| Internal field for external Id | External_Id__c |
| Internal Object***** | Addresses__r |
| Is Active | True |
| Object Mapping Name | 03 I Customer => List<Address> |
| Operation Type | Insert |
| Parent Object Mapping | Details mapping (e.g. **02 I Customer => Account (Details)**) |
| Service Provider | <your service provider name> |
| Sync Direction | Inbound |

> ℹ️ For the child mapping, we should specify the child relationship name in field Internal Object. See screenshot below.

|  |  |
| --- | --- |
| ![image]() | ![image](media://62bd1cc0-a029-4bd7-bc3e-004b371b5b37)<br>![image](media://5d968e26-0ea4-4446-8d7a-387a024f6d08) |


** As an external object, we should specify the name of the node containing a list of nodes with child objects information. See screenshot below.  
*** If the external id is the attribute value (e.g. **id**), then the name should consist of the name of the node (e.g. **address**) and the attribute name (e.g. **id**) of this node, enclosed in square brackets. See screenshot below.

|  |  |
| --- | --- |
| ![image]() | ![image](media://d519900f-9384-43fa-a865-56b1e0d3d62d) |


#### Steps - Creating the Field Mapping

**List field mapping**

Field mapping is not required to get a list of existing records, but to pass a validation it should contain at least one field mapping.

1. Go to the **List** object mapping.
2. Click the '**New**' field mapping button.
3. Select '**Twinfield**' recordtype and click '**Next**'.
4. Input the following data by creating Field Mapping (Use the Object Mapping '**01 I List<Customer>**' for Field Mapping you make).
5. As result, something like the screenshot below should be shown.  
> Macro (inline-media-image)

  
**Details field mapping**

1. Go to the **Details** object mapping.
2. Click the '**New**' field mapping button.
3. Select '**Twinfield**' recordtype and click '**Next**'.
4. Input the following data by creating separate Field Mappings for each row in this table (Use the Object Mapping '**02 I Customer => Account (Details)**' for every Field Mapping you make).
5. As result, something like the screenshot below should be shown.  
  
> Macro (inline-media-image)


**Childs object mapping**

1. Go to the **Childs** object mapping.
2. Click the '**New**' field mapping button.

1. Select '**Twinfield**' recordtype and click '**Next**'.
2. Input the following data by creating separate Field Mappings for each row in this table (Use the Object Mapping '**03 I Customer => List<Address>**' for every Field Mapping you make).
  
  


**Validate your Salesforce fields**

After creating all the lists, return to your service provider and press the 'Validate mappings' button to validate your fields and see if you didn't make any mistake.

![image](media://c096c2ae-9f9c-4794-89e2-f9cbf22f4721)

You are done and ready to test the Inbound Data Sync.


# **Object Mappings for the Outbound Data Sync**

The Outbound Data Sync pushes the triggered record to the external system according to the Object Mapping configuration. In the following chapters a few example configurations will be created in a step-by-step process.

### Exporting Invoices

In this example FieldBuddy Connect will be exporting Invoices from Salesforce to the Twinfield. Make sure to have a Twinfield trigger on Invoice. 

If we want to send a composite object (e.g. **Invoice** and **Invoice lines**) to Twinfield, then we should create object mappings for the parent object (**Invoice**) and for the child objects (**Invoice lines**).

#### Steps - Creating Parent Object Mapping

1. Go to the Page 'Object Mapping'.
2. Click the button '**New**', select '**Twinfield'** recordtype and and fill in the following data.  
> Macro (inline-media-image)

#### Steps - Creating Child Object Mapping

1. Go to the Page 'Object Mapping'.
2. Click the button '**New**', select '**Twinfield'** recordtype and and fill in the following data  
> Macro (inline-media-image)

**Parent field mapping**

1. Go to the **Parent** object mapping.
2. Click the '**New**' field mapping button.
3. Select '**Twinfield**' recordtype and click '**Next**'.
4. Input the following data by creating separate Field Mappings for each row in this table (Use the Object Mapping '**02 I Customer => Account (Details)**' for every Field Mapping you make).
  As result, something like the screenshot below should be shown  
> Macro (inline-media-image)
  
  

**Child field mapping**

1. Go to the **Child** object mapping.
2. Click the '**New**' field mapping button.
3. Select '**Twinfield**' recordtype and click '**Next**'.
4. Input the following data by creating separate Field Mappings for each row in this table (Use the Object Mapping '**02 I Customer => Account (Details)**' for every Field Mapping you make).
  As result, something like the screenshot below should be shown  
  
> Macro (inline-media-image)

  
  
> Macro (inline-media-image)