I am trying to import a excel file using Upload widget
Question
Service Studio Version
11.10.12 (Build 39237)

Hello am creating a simple screen to upload records from excel to database and show on screen. I have attached my codebelow, please help to see if i am missing anything. I have created correct server action and screen action. When i press the import button, data from excel is not saved in DB.

Following are the process

1. select a file from a location

2. click on import button will call an action which will do following

   a. Get DB recs, delete if DB is not empty

   b. When DB is empty, get the recs from execl to the record list for each record.

Test.oml

mvp_badge
MVP
Solution

Hi Stock Analyzer,


The file you were using is one in Resources, that you saved in the eSpace, not the one you are uploading:


I fixed it in the new OML in attachment.

Test4.oml

Hello,


I believe this is where you went wrong.

You are pulling the data from the Aggregate GetPersons where in fact it should have been from the Excel File.

It will also be easier if you will use the Entity itself on your ConvertFromExcel, just make sure your structure or whatever is placed there is aligned to the Entity you are inserting data to.


I also uploaded back the copy of your oml with my adjustments. Feel free to try it out.

Let me know if you still have questions.

TestTryThis.oml

Hi,

When i try to use your version with server action "Try this", Db looks the same as before, but it shows only 2 records out of 5 records in the file. When i use my server action "Action1", all data is deleted from db, but it creates 2 dummy entry (as attached)

DBCreationerror.JPG

mvp_badge
MVP

Hi Stock Analyzer,


You were missing assigning the values from the excel in the for each, line by line, and then having the record with the values of excel inserted in the database. For that I created a record of type Person, and for each excel line, I fill the details from Excel (Name, birth and Death) to that record that will then be inserted in the database, like on the picture below: 


In attachment you can find with the aforementioned changes.


Kind Regards,
João

Test4.oml

Hi,

I have tried your version, still have a small problem. 

1. Used import excel bootstrap to create the Person entity (there was 2 record at the start) - in my initial version

2. After running your code, existing data (2 records with ID 1 & 2) are deleted and same data is created with ID 3 & 4. But my excel file has 7 records now which is not inserted into DB.

To Sum up, still records from my excel is not inserted into DB. I have atatched the new input file I have used.

Book4.xlsx

mvp_badge
MVP
Solution

Hi Stock Analyzer,


The file you were using is one in Resources, that you saved in the eSpace, not the one you are uploading:


I fixed it in the new OML in attachment.

Test4.oml

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.