Import data

Import data is used for importing data from a CSV-file, Text-file or JSON-file, and store these as objects in Appfarm.


Source Format

The file type of the file to be imported. CSV, Text and JSON is supported. Note that you may create CSV files from Excel ("Save as" -> CSV (UTF-8)).

Source Type

  • File: The File Browser will open when this action node is executed, to allow the end user to select the file (according to the Source Format) to be imported. This option is only available when Import Data is used in Apps, not in Services.

  • URL: Instead of opening the file browser, you may enter an URL to retrieve the file from.

  • Text: Instead of retrieving a file (from the file browser or URL) you may define the CSV, Text or JSON content yourself as part of the action node. E.g. you may construct the rows of a CSV file yourself.

Result parser (Optional)

If you need to process the data imported from the document before mapping it to a data source you can write a function in the result parser. The raw import data is provided as a parameter.

For CSV files, the raw import data is an array where each element represents a row of data. Each element is again an array, with each element representing a column. The return value should be of the same structure. The first row will be included, even if you have selected Ignore First Row.

CSV result parser
// Example structure
  ["First name"," Last name", "Email"]
  ["Jess", "Renner", ""],
  ["Carolyn", "Green", ""],
  ["Frank", "Williams", ""],

For JSON files, the raw import data is an object or array dependent on the original structure. The return value should be of the same structure.

JSON result parser
// Single object
    "firstName": "Jess",
    "lastName": "Renner",
    "email": ""

// Array
    "firstName": "Jess",
    "lastName": "Renner",
    "email": ""
    "firstName": "Carolyn",
    "lastName": "Green",
    "email": ""
    "firstName": "Frank",
    "lastName": "Williams",
    "email": ""

Data Source

Select the Data Source you want to import data into. The Data Source must be Runtime Only. See section Usage below.


Map column-by-column of the CSV file (or JSON / Text file) to a property in the Data Source. If you want to import all columns of a CSV file with 4 columns, you must add 4 column mappings. See section Usage below.

Ignore First Row

By ticking this checkbox, you will not import the first row, which often contains column header names.


For CSV files, the delimiter between columns may vary. In the US, the delimiter is normally comma (,) whereas in Europoe it is normally semicolon (;). Appfarm will try to autodetect this, but in the cases you know the delimiter, you may specify e.g. a semicolon here.


Assuming you have created an object class in the Global Data Model, with properties for storing this data, you now want to import data from a CSV file, storing each row and properties into this object class/database.

An example setup of Import Data is showcased in our Showroom! You may view a demo, as well as access the setup in Appfarm Create. If you do not have access, you may register here.

Import Data is also explained here, by providing an example case:

We have the Object Class "Invoice" with 4 properties "Invoice Number", "Amount", "Date" and "Description".

  1. Add this as a data source in App Data (e.g. "Invoices (temp)). The data source should be Runtime only, with cardinality "Many". Note that, with both Import data and Web requests, you may only populate "Runtime only" data sources directly from the action node.

  2. Add the action node "Import Data" and set the Data Source setting to "Invoices (temp)"

  3. Add target columns: If your CSV holds 4 columns - add 4 target columns. For each - set which property in Invoices (temp) the column should map to

Note that sometimes the format within the CSV does not match 1-to-1 to the built-in data types of the data source. E.g. a "date" in a CSV file may be formatted differently for different CSV files.

When mapping your columns, you may set a Format:

  • Date types: If the CSV file holds dates such as "24.12.2020" you should set the Format to "DD.MM.YYYY". If the CSV also holds Time (e.g. 24.12.2020 10:00), the Format should be "DD.MM.YYYY HH:mm".

  • Float types: If you are mapping towards a float datatype (e.g. when mapping the CSV column "Amount" to property Invoices (temp).Amount) - the decimal separator may be "," in some files, and "." in others. The default value being interpreted is ".", so you must explicitly state "," if your CSV file holds decimal numbers such as "225,50".

Note that if "Invoices (temp)" has a property "Customer" being an object reference towards the Customer object, you need to deal with this the following way:

  • Your file holds "Customer No", which is a property of the Customer object, not the Invoice object: Navigate to App Data -> Invoices (temp) and add a runtime only property to this data source ("Customer No temp" for instance, with data type Integer)

  • Map the "Customer No" column of your CSV to "Customer No temp"

After the Import Data action node, you may set the Customer reference, best and most efficiently implemented by using an Update Object (update All objects in Invoices (temp)):

  • For the property "Customer" - use a Function

  • Assuming you have a data source "Customers" holding all customers: Add "Customers" as a Function Parameter, and set a filtered selection on this function parameter with filter "Invoices (temp).Customer No temp Equals Customers.Customer No". The list of customers added as a function parameter will be filtered down to 1 object (or 0, if no match)

  • Write a function: return "customers[0]._id". This returns the built-in "id" property of the first record in the list. Yes, it's still a list even though it has been filtered down to a single item.


CSV files are often saved with different encodings. The best format for importing with Appfarm Create is "CSV UTF-8".

JSON result parser

Last updated