Betty Blocks has its own import functionality. You can enable this function on any model you want. This will enable you to import data from an Excel or CSV file directly into a model. After following this HowTo tutorial you will know how you can import data to your application.

Enabling import settings

To be able to import data to a model, this first has to be enabled in the model's settings.

  1. Start by going to the Data Model by clicking on the Data Model icon in the Builder Bar.

  2. Click on the model that you want to import to. The model settings will slide in from the right side of the screen.

  3. Within the model settings, click on the Edit button on the upper right corner of the screen.

  4. Enable the Allow import setting to enable the import function for that model.

  5. Click on the Save button on the upper right corner of the screen to save the model you are editing.

Setting up an import definition

If importing is enabled on the model that we want to import to, we can start importing data to our application.

  1. Go to the Back Office by clicking on the Back Office icon in the Builder Bar.

  2. Select a Grid from the Sidebar that you want to import to.

  3. Click on the Import button next to the New button.

  4. The Import modal will pop up. In this modal, you can select the file that you want to import. You can either select a file through your file selector, or drag and drop it inside of the model. Only an Excel or CSV file will work for the import.

  5. If the file is uploaded correctly the Next button will appear. Click this button to continue importing. 

  6. In the next modal we have to assign the columns of the file to the properties of the model. By clicking on the specify path button the model browser will pop up.  In this modal, you can choose the property that you want to assign the column to.

  7. There are some other settings that you can use to improve your import. These settings are mentioned here: Import Reference

  8. To save the import definition enable the Save definition option. If you are done with setting up the import click on the Next button to execute it.

  9. The records will be created according to the import definition. When the import is finished you will receive a notification. 

Using importing with actions

Importing can also be done via actions, this way it is possible to automize imports. To be able to create an import block an import file and import definition has to be saved within the application. Let's say that every week companies send you updated data of their products in an import file. They will probably want this information in the application as fast as possible. The best way to do this is to automate it with an action.

  1. Go to the Actions by clicking on the Actions icon in the Builder Bar.

  2. Create a new action by clicking on the New button on the upper left side of the screen.

  3. Choose a description and a model for the action, note that the import file has to be saved in the chosen model. In our case, the chosen model should be the model of the companies, since this is where they would upload their files.

  4. Click on the Save button if you are done with setting up the action.

  5. Now create a new action event for the action by clicking on the plus icon inside of the action.

  6. A new action block will be created. This block should be set to an Import event, this can be done in the Kind drop-down. By doing this the form will get the right format to set up the import.

  7. An object that contains the import file should be selected, this can be done by clicking on the Click to set button. By clicking this button the Variables browser will pop up, in this browser you can choose an object for you import.

  8. Choose the import definition that should be used with the import, if none can be chosen then it should be created within the import configurations.

  9. Choose the file property from the previously chosen object, if there is one file in this object then the file will get automatically selected.

  10. If you are done with setting up the action block you can click the Save button to save it.

  11. You can continue with creating your action to add specific rules to the execution of the import. If you are done with creating your action you can press the Save button to save it. 

Using imported records in a callback action

After importing a file by using an action, you may want to process all records. This can be done with a callback action. For example, if each imported record needs to be sent by email.

  1. Go to Actions by clicking on the Actions icon in the Builder Bar.

  2. Choose an action that uses an import event, or create one by following the steps above.

  3. Select the import event of the action and click on the Edit button in the top right corner.

  4. Scroll down and check the Enable callback action checkbox, this will show additional input fields.

  5. Check the Process imported records checkbox to automatically use the imported records within the records variable of the action.

  6. Choose an action to execute after the import, or create a new action by choosing - New -. Note that if the Process imported records checkbox is enabled, you'll only be able to choose actions that are a batch action and are built on the same model as the imported records.

  7. Optionally, you can choose to enable the Execute all action in foreground checkbox, which sets the callback action to run in the foreground if this is set to background.

  8. Click on the Save button in the top right corner to save the import event.

  9. In the chosen callback action, enable the Preserve collection checkbox to use a collection of all records in the action (input variable records). If this option is disabled the action will be executed once for every record (input variable record).

This callback action will trigger when the last record is imported in the import event. It will then use all records from the import to start a batch action. More about callback action can be found in this article: HowTo use callback actions

Did this answer your question?