Smart Data Flow Development
We will start by developing a Smart Data Flow to fetch Inventory information from the Inventory Master Data that you created as part of the assignment. For this tutorial we will be using the Computer Inspection form that we enhanced earlier
Prerequisite
Section titled “Prerequisite”Equipment Inventory Master Data
Section titled “Equipment Inventory Master Data”Recall that the Master Data Form design had a couple of assignments. We will be using the Equipment Inventory Master data from that assignment.
If you have not yet completed that assignment, do so now so that you can continue with this tutorial.
Smart Data Component Form Design
Section titled “Smart Data Component Form Design”You should have also completed the Smart Data Component Form Design tutorial.
If you have not yet completed that tutorial, do so now so that you can continue with this tutorial.
Flow Development
Section titled “Flow Development”- In the Forms list, click on the
Flowsicon on the Computer Inspection row - A list of Flows will be displayed. Now click on the
Query InventorySmart Data Flow that we created earlier - You will now be navigated to the Flow Builder
Understanding the steps
Section titled “Understanding the steps”Before we develop the flow, let us draw a flow chart of the different steps we need to perform to check for inventory.
flowchart TD
A([Start]) -->|From SDC Action| B[Extract Equipment ID]
B --> C{Error}
C --> |No| D[(Search Master Data for ID)]
C --> |Yes| E([ReturnError])
D --> F{Error}
F --> |No| G([Format Return Value])
G --> |No| H([Return Inventory Count])
F --> |Yes| E
Developing the Flow
Section titled “Developing the Flow”- In the Flow Builder, the
Add Nodedialog should already be open. If not, click on theSmart Data Flowstart node and then click on the :fontawesome-solid-circle-plus: icon that is displayed below the node - Search for the
JSON Parsernode by typing in json and clicking on it - The
JSON Parsernode is now opened and you can configure it.- Change the title to
Extract IDand remember to connect theSmart Data Flowstart nodeSuccessconnector to this node - Since we want to work with the Form Data, click on the
Form Fieldssection - For
Map Field NameselectForm Data - Under
Expressionclick on the :fontawesome-solid-wrench: icon to open the Expression Builder - To extract the Equipment ID we need to know what format the data is going to be submitted. In the Expression Builder windows, click on the :fontawesome-solid-rectangle-list: icon to open the data format screen.
- Now the previously saved Form (test) data format is displayed in the JSON editor. If the Form (test) data is not yet configured please do so first. Click on the editor, select the entire JSON and copy it.
{"inspectDateTime": "2024-03-07T03:45:09.000Z","equipment": "cpu","inventory": "","condition": "warning","equipmentImage": [],"inspectedBy": 1,"comment":"Warning comment","signature": "data:image/png;base64,iVBORw0K ......... AAEl==","branding": {"data": {},"metadata": {}}}
- Paste the data into the
JSONwindow on the left - The expression builder we use for JSON parsing is a tool called Jsonata
- We now need to extract only the equipment field to search for and the expression for that is:
$.equipment
- Paste the expression from the step above into the
Mapping Expressionwindow on the right. The extracted data is now displayed at the bottom. Confirm that what is displayed is correct. - Now click on
Saveand close the builder, - Now click on the :fontawesome-solid-floppy-disk: icon and save the node
- Change the title to
- Now we need to search for Inventory Master Data. Select the
Extract IDnode and then click on the :fontawesome-solid-circle-plus: icon. Search for theRead Rowsnode by typing in master data and clicking on it - The
Read Rowsnode is now opened and you can configure it.- Change the title to
Search Inventoryand remember to connect theExtract IDnodeSuccessconnector to this node - First we need to select the Master Data we need to search. Click on the
Master Data Entitydropdown and selectEquipment Inventory - We want to search for the equipment ID we extracted earlier. Under
Master Data Filterclick on the :fontawesome-solid-wrench: icon to open the Query Builder - A condition builder is now displayed. Click on the :fontawesome-solid-plus: icon to add a condition
- Choose equipmentId as the
Field, Equals as theCondition. - In the custom text field, click on the :fontawesome-solid-wrench: icon to open the Expression Builder and select the Result under
Extract IDand click on Save - Now click on the :fontawesome-solid-floppy-disk: icon and save the node
Connect the
save-form-datanode to Success
- Change the title to
- Now we need to send a properly formatted response to the SDC. Select the
Search Inventorynode and then click on the :fontawesome-solid-circle-plus: icon. Search for theJSON Parsernode by typing in json and clicking on it - The
JSON Parsernode is now opened and you can configure it.- Change the title to
Prepare Count Dataand remember to connect theSearch InventorynodeSuccessconnector to this node - Since we want to work with the retrieved Inventory, click on the
Previous Stepssection - For
Map Field Nameselect Result underSearch Inventory - Under
Expressionclick on the :fontawesome-solid-wrench: icon to open the Expression Builder - To extract the inventory we need to know what format the data is going to be submitted. The search inventory returns data in this format:
{"data": [{"equipmentId": "computer","submit": true,"inventory": 10}]}
- Paste the data into the
JSONwindow on the left - The expression builder we use for JSON parsing is a tool called Jsonata
- We now need to extract the inventory and format the message using this expression. The SDC will update the form with the data that is returned by looking for form fields inside the
dataattribute in the JSON, hence the format below.$.{"data":{"inventory" : $exists(data.inventory) ? $string(data.inventory) : ""}} - Paste the expression from the step above into the
Mapping Expressionwindow on the right. The extracted data is now displayed at the bottom. Confirm that what is displayed is correct. - Now click on
Saveand close the builder, - Now click on the :fontawesome-solid-floppy-disk: icon and save the node
- Change the title to
- Last step, we need to return data exactly how the SDC expects. The format of the data format is already configured in the
Prepare Count Datastep above. Now we will configure the response. For this click on thePrepare Count Dataand click on the :fontawesome-solid-circle-plus: icon that is displayed below the node - Search for the
Responsenode by typing in response and clicking on it - The
Responsenode is now opened and you can configure it.- Change the title to
Send To Formand remember to connect thePrepare Count DatanodeSuccessconnector above to this node (else the expression builder will not display all the possible fields and nodes) - Select the Success option
- Set the
HTTP Codeto 200 to signify HTTP Success - For
Bodyclick on the :fontawesome-solid-wrench: icon to open the Expression Builder - Select Result below the
Prepare Count Dataentry - Now Click on the :fontawesome-solid-floppy-disk: icon and save the node
- Change the title to
- Now click on Publish button to save and compile the flow. If the compilation is successful it will also be published and we can run it to test.
Testing the Flow
Section titled “Testing the Flow”- Now that we have published the flow we are ready to test it. The Flow Builder has an integrated Run and Debug tool to help us troubleshoot the flow in case of errors.
- Now click on the Run Flow button. The Run dialog is now displayed. You can now enter Form (test) data now by clicking on the
Form Databutton. Select any equipment for which you will fetch the inventory. - Run the flow by clicking on the
Runbutton. The flow should run successfully. - If there are errors it could be due to some mistakes while configuring the system or copy/pasting the expression or similar. Check each step carefully with the documentation above.
- You should see the result with the required inventory count.
- Go ahead and select a different equipment in the Form (test) data and
Runthe flow again. You will see a new inventory count now.
Testing the Flow in the Turbo Apps Builder
Section titled “Testing the Flow in the Turbo Apps Builder”- From the Forms list, click on the
Inspection Formrow to display the Form Designer - Click on
Preview - Choose any Equipment and click on the
Check Inventorybutton - The Inventory displayed should be updated now on each click
Login to Turbo Forms App
Section titled “Login to Turbo Forms App”Now login to the Turbo Forms App on web or mobile as the same user and click on the + button to create a new form to fill and choose the Computer Inspection form. Choose any equipment and check its Inventory by tapping on the Check Inventory button
Topics Covered
Section titled “Topics Covered”- Developing a Smart Data Flow to update inventory online
- Extracting the equipment ID and searching in Master Data
- Creating Form (test) data
- Running the flow and testing it