If you want to update the data in Business Central during any operation, you need to make two steps:
Let's have an example with a GET Multiple Records operation for Contacts. The operation returns following response:
Let's now say that you would like to achieve following results:
email
node, create new contact in Business Central.address
, city
and countryCode
only).Tip: In a real scenario you would probably download and update only new or changed records. See how to do that in Synchronize data guideline.
Select your operation and open the response body with Response Body action. Now select the node with Type Table
and open Home / Details:
Pay attention to the Connections tab – you need to fill in following fields:
Create
if you only want to create new customers.Update Only
if you only want to update existing customers (not create new ones).Create or Update
if you want to create new customers and update existing ones.Tip: If you are searching by E-mail field, it's advisable to add a key for that field, too – and update the Table View like this:
SORTING(E-mail) WHERE(E-Mail=CONST({{!Field102}}))
.
But if you try to Release the operation now, you will get an error:
There is one more step to go – setting up a RapidStart package.
The RapidStart package is set on operation level. Select your operation from the list and open Details from the menu:
Go to the Response tab and first fill in the Insert Package Code field (this RapidStart package will be used for inserting new records). If you have a package ready, you can just select it, but let's now create a new one:
Table 5050 Contact
.These settings tells RESTwithUS, which fields can be updated during record insert. Let's say that for an insert you want to have as much information as you can, so leave all fields checked. But if you for example uncheck the Include Field option for an Address
field, this field won't be updated by the operation – even if it is in the response body definition.
Now let's do the same for the Modify Package Code field:
The settings are almost the same like for the insert package, the only difference will be in table fields:
In this example, you want to update only address
, city
,and countryCode
info from an external system – and leave the rest of the fields as they are. So first clear all checkboxes with Clear Included function and then check them just for fields Address
, City
and Country/Region Code
.
Please note that in the response body there is the contact name
node too:
But since you did not include the field Name
in the modified RapidStart package, only the address fields will be updated for existing records.
Now you can Release the operation and test, if the data are properly updated in Business Central.
Tip: You can use the same packages for more tables and operation. Recommended setup is to have one insert and one modify RapidStart package per provider.