1.1 Create an Entity from an Excel File
1. Create Full-fledged Pages in an Instant
1.1. Create an Entity from an Excel File
in the next lessons we will create an application to manage Suppliers
will use some accelerators to scaffold the application fasten easy
we'll start by modeling entities and importing data for them
let's start by creating our web application
and will call its Suppliers and lets
add a new eSpace module to our application
first to model the entities in our application you know
that we need to go into the data tab and before we start
creating here the entities let me just show you the
Excel file with the data that we're going to import into our application
this is a Supplier list
and it has here a bunch of suppliers where we have
their name and email, a phone number
and address and a website and you notice here that
not all of this information is filled in for instance the phone number is not
present for this supplier
as well as the website OK?
so before I continue, I'll need to close the Excel file
and let me disclosed here, and now instead of creating the entity
and then bootstrapping the data, I'm going to use another option here
on the Entities folder, right-click I'm going to use this option here
import entities from Excel and
I will choose the suppliers Excel file that you just saw
and you'll notice that
a bunch of star started showing here
in our application and what just happened is that
this entity Supplier here was created
based on that Excel file and for
each column in the Excel file an attribute is created
that matches the top row of that column. The datatypes
and the mandatory property of these attributes are also inferred by the OutSystems
Platform so we have here
the name, the email
and you'll notice that the data types are inferred by the platform
the phone number, the address
and the website, and if you recall from data on the Excel file
the phone number and the website were not filled-in in all the rows
so this means that they are not mandatory in our
entity and the other attributes are
inferred as mandatory. Apart from all these attributes
the platform also creates an identifier for our entity
now besides this entity that was created
other objects were created in
in our application, so let's see what objects were created. In the logic
tab you'll notice that under the actions folder
we have an action and this
action is pretty much what we've seen in previous lessons
this is the action that bootstraps the data for this
entity and the data comes from this Excel file that we just saw
let me just drill down here on this action and you notice that
the logic that is here on this action this is not that complex logic
and basically what this action does that it retrieves the information from the Excel file
using the Excel to Record List tool
which is this tool here and its stores this information
in the database to accomplish this
the Excel file itself needs to be embedded as a resource
under the resources folder on the Data tab so
here on the Data tab under the resources folder
we will find our Excel file. Now
you've seen here the logic that creates these suppliers based on the data from
the Excel file
the question that remains open is but when does this logic
get executed and to answer that question I'll need to show you
another object that was created by this
action that we just did. Here under the
Processes tab you'll find a folder called Timers
and here you will find the BootstrapSupplier Timer
A Timer allow to execute logic asynchronously
on a specific schedule. In this case the Timer is
triggered when the application module is published. And you'll notice this
by this property here Schedule - When Publish
And the logic that the Timer
executes, is enclosed in this action that we're seeing here
the BootstrapSuppliers action the action that we have
actually opened here in our application
In the next lesson will create a list screen to show the data from this Excel file
And that's it
No file chosen
Login to reply
Posted on 2015-12-16
I took a look but didn't see anything strange.
Let me try to guide on what's happening behind the scenes so that you can overcome this issue.
When you select the excel file a mapping is done between the excel columns and the entity attributes. This mapping is done by name and a dialog shows this mapping. This is usually the first step that can go wrong, you have different names and the mapping leaves some information out. Apparently this is not your case.
This excel is stored as a resource in your module and some logic is created to read the excel rows and to put that information in the database. This logic consists of a Timer that executes an action when you publish the module.
The logic in the action itself is relatively simple:
Check if there's already data for that entity in the database, using an aggregate;
transform the excel content in a list of records (using an ExcelToRecordList) with data type set to a structure that was created with the columns that were mapped from the excel file;
Cycle throught the list and create records in the database.
Now if you already have data in the database the action stops right at the beggining to prevent from having duplicates every time you publish your module.
So, my suggestion is that you place some breakpoints in the bootstrap action. And use the debugger to go over this logic step by step and determine why your data is not being stored in the database.
Sorry for the long answer, I hope it helps.
Posted on 2015-12-13
Included the model. I hope you can determine what's wrong here.
Thanks in advance!
Posted on 2015-12-09
There's a couple of things that might have happened. Can you possibiy share your module so that we can have a look at it? You can export it using Ctrl+S and attach it here in another post.
Posted on 2015-12-07
I tried importing contacts from my own excel file, but on runtime, after the bootstrap was executed I don't see any contacts in the screen in my personal environment. I used the debugger to trace the code and I see it's executed correcly 'when published'. What did I do wrong here?
Thanks in advance for your answer.
OutSystems© All rights reserved. Custom built with