This is an old revision of the document!
Introduction to DataBuilder
This document described the use of the Bizweaver DataBuilder tool. This tool is used to create JSON and XML data structures for use with web service APIs.
The following documents contain additional information that may be helpful with the development of Bizweaver workflows.
Before You Begin
You will need to know, or have examples of, the data structures the API is expecting. This includes an element (field names) and child objects within the structure. Keep in mind that names will generally require an exact match, including case.
For SAP Business One Service Layer
An easy way to view the data structures used for SAP Business One is to create a small workflow that executes a GET on the object in question. The workflow will have two WebService2 steps: a login step and a GET step. The GET step references the target object (e.g., SalesOrders). The GET step will return the data structure for the object in the “Output String.” This is also an easy way to create a template file for the object in your environment as it will include any user-defined fields as well.
More information dealing with SAP Service Layer can be found here
General Notes
Input will generally be from a SQL Reader step.
The example used on this page is for JSON. The same general process is also used for XML.
General Process
Create an input (SQL Reader) step for each dataset that will be needed. An example would be order header and order lines.
Create a DataBuilder step for each dataset.
Once all DataBuilder steps are created, add the lower-level datasets to the main dataset. Their Object Name references the lower-level datasets. These are listed in the “Field Type” drop-down after they are created.
The “CumulativeData” variable from the main DataBuilder step is referenced in the web service step that transmits the
API's information.
Databuilder
Tool Name: This is the name given to the tool. This will be displayed in the design canvas as well as the variable selector
Description: A space for notes about the tool.
DataSource Object: This is the source of data for the Databuilder.
This is required and is always a SQL/HANA tool.
Hint the number of rows you feed into the databuilder from the subsequent SQL step determines the number of sections is output. This is more helpful when dealing with XML over JSON but keeps this in mind while generating JSON or XML the SQL statement and the database for the databuilder step.
Data Type: This determines the type of file that is generated.
Add as an Array: this will add an array to your JSON or XML.
Arrays will be displayed in the Field Type drop-down
If selected, it will insert the Array into the JSON or XML where it is located in the list.
Top-Level Element: This clears the JSON or XML data if it is contained in a loop, so subsequent processes do not build on top of the previous cycle.
This is generally used to update one thing at a time. If the
API used can be updated with one large JSON or XML file, this option can be un-selected.
Create New Object: The Object name of the JSON or XML structure.
This can be used to create multiple levels of XML or JSON (see example below)
Preview Box: A preview of the JSON or XML that is being built.
Name-Value Pair:
Field Name: The name of the name-value pair
Field Type: This can either be String, Numeric, Boolean, or an Array built later in the workflow.
Value: Normally a variable from the connected SQL/HANA step. These can also be hard-coded values.
Add Row or Delete: 
The down arrow will add a row below the current row. The “X” will delete that row.
JSON Example
Below is an example of how to build a basic JSON File. The data is coming from SAP but this concept applies to any API being used to pass data to.
Start by getting all the data needed and process that through a loop as we only want to process one record at a time in this example.
Once the data is sent into the loop you will limit it down to one record and add link it to the next step which is the data builder step
In most cases the lower-level sections will need to be marked as an array. The “Add as an array” checkbox should be selected. However, always check your API documentation to verify this. At the same time, the “Top-level Element” checkbox should remain cleared.
When creating lower-level section that may have more than one entry (i.e. an array), be sure to put the DataBuilder tool within a Loop. As each record is read from the input it is added to the bottom of the array being constructed. Not using a loop will result in an incorrect data structure.
Once the JSON is built it the Cumulative data variable from the Header step can be used and entered into the body section of a Web Service 2 tool to then be sent through the
API.