1.4.3 – Bulk Import Clients and Export data
In the previous topic, you have managed to add one Client to the database. Now, let’s try to develop a way that would allow you to bulk import multiple Clients at once.
- Add a flowchart Clients – Bulk Import in the Subflows folder.
- In the flowchart, drag the Import node into the canvas. This will show you a prompt, where you can select whet
- her you want to import from JSON or from XML or from CSV/MS Excel. Select the last.
- Click the node to see the Properties panel to the right.
- You need a Data Source and a Destination. The latter would be the Clients list in the data model. For the former, you need to add a Session field of type File. Use this session field as the Data Source.
- Click on ‘Edit mappings’.
- You will be presented with an overlay as you see in the second screenshot below, but with empty rows.
- Under the ‘Column name’, you fill in the column headers that will come from the Excel file. Under ‘Map to’, you can select the appropriate fields from the Clients list.
- You might recollect from the the Company name was a mandatory field in the previous topic where you had added a row by filling-in a form. Let’s retain the validation here. So, check the box under ‘Required’ for Company name.
- Leave the other fields as they are. Click on Save.
- Add a ‘Save database list changes’ node after that and then finish it off with an End node.
- In the Clients overview screen, add a Button, on click of which should invoke this flowchart.
- Now, create an Excel file with 4 headers. Note that the headers should match exactly with the names in ‘Column name’ field in the mapping that you had just completed.
- Fill-in two or three rows of sample data and try the bulk import yourself.
Did you see how simple that was? You can in fact make it even simpler, by simplifying the mapping steps. Do you see the ‘Create mapping from example’ button at the top of the above screenshot? You could click on that and import the sample Excel file. Once the file is selected, WEM will show a list of all columns from the source file. You can now specify per column to which target field in WEM the data should be mapped / imported. If needed you can also specify whether this should be a mandatory field and what do do when WEM encounters an invalid value in the source file. Delete the Import node and add it again to try this out.
While we are here, let’s also learn about the Export node. Just as you were able to import from JSON or from XML or from CSV/MS Excel, the Export node allows you to export data from a database/transient list into one of these file formats. The configurations for the node are quite alike. So, perhaps you could try building a simple export functionality on the ‘Customers’ page?