---
title: "Exporting Work Orders to SalesOrders"
canonical: "https://help.fieldbuddy.com/space/FBDOCS/2078310830/Exporting%20Work%20Orders%20to%20SalesOrders"
format: markdown
---
In case you require to sent data from multiple objects that related to each other via master-detail. This guide will explain to you how to configure this.

# Inserting SalesOrders in Exact Online

This example is going to be applicable for the [SalesOrders](https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=SalesOrderSalesOrders) and [SalesOrderLines](https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=SalesOrderSalesOrderLines) object in Exact Online. Some facts about these objects:

1. It is impossible to insert (POST) a SalesOrder without SalesOrderLines. Doing this will result in an error: [500 Internal Server Error](https://upperdeck.atlassian.net/wiki/pages/createpage.action?spaceKey=FBCN&title=Errors) - No order lines. Order lines must be supplied to create a new order
2. It is impossible to insert (POST) SalesOrderLines without a SalesOrder.
3. It is impossible to update a SalesOrder(PUT) while sending SalesOrderLines. Doing this will result in an error: [400 Bad Request Error](https://upperdeck.atlassian.net/wiki/pages/createpage.action?spaceKey=FBCN&title=Errors) - Processing request stream. Binding to new entities is not supported in PUT operations.

This implies the following. Having an object mapping set to 'Upsert' on the parent-object (SalesOrder) is useless due to fact #3. Because with each update on the parent record, it will sent the underlying children. Which results in the error listed in #3. Either update (without children) or insert (with children) can be used (in combination).

## Create the parent object mapping

1. In order to configure the outbound, you require the following to create the following object mapping:
  
2. Make sure the
  1. Internal field for external Id is properly configured (including field permissions). This field should be a Text (255) Unique Id, External ID.
  2. Internal field for Last Sync Datetime API is properly configured (including field permissions). This field should a DateTime field.
  3. Internal field for Sync Check API is properly configured (including field permissions). This field should be a Checkbox, default off.
  4. The Checkbox Is Active is set to TRUE.
3. Create a trigger on the object. Read here how: [https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/2078311179](https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/2078311179)

## Create the field mappings for Parent Record

1. Create the following underlying field mapping on the Parent object mapping
  1. In case of a SalesOrder a OrderedBy field is required
2. Example of a field mappings
  

## Create the Child object mapping

In this example, there will be one children (master-detail) that will be sent as SalesOrderLines - FIELDBUDDY__Work_Order_Line_Item__c

![image-20240826-084951.png](media://677d33ce-1873-4929-b123-7e16925f1bba)

## Create the Child Field Mappings

Children records Operation Types can only set to: Insert or Delete. This is due to the fact that the object mapping is set on the parent record, so is the trigger. So updates on children records are not handled by this object mapping. A separate object mapping should be created in that case. 

![image-20240826-085029.png](media://4c23bbb2-e14c-435d-8000-c430e01d0090)

  
In case of a parent-children configuration, the system performs an additional call after inserting the records in EOL in order to retrieve the EOL Id. In order to do the call(get), it requires a unique identifier. You can not have multiple line items having the same identifier. This will cause the system not to update your line items with an EOL id. A outbound configuration for children requires a field that is a Reference Type and an Is `External Mapping Field set` to true. 

![image-20240826-085323.png](media://fc7b57b9-dbdc-4ac7-9d8c-d13bdb281b10)