Bootstrapping from the xlsx file to an existing entity already filled with data

Bootstrapping from the xlsx file to an existing entity already filled with data

  

I want to bootstrap a xlsx file to an existing entity already filled with data. My doubt concerns the sixth step. See below please. Thanks. 


The steps I have done follows:


1. I have imported the xlsx file in the RESOURCES folder (With the import resource option);

2. I have created a structure with exactly the same attributes as the entity. There is only one attribute that is not present in the xlsx file - it should receive NULL values for now (it will be fed later by another entity that has the info needed);

3. I have created an user action called upload_file . With the excel to record list widget I set the Record Definition parameter with the structure created in the 2. step  IN file content I have set the xlsx file present in the resource folder;

4. In the user action I have created a local variable with the ENTITY type (to which we need to feed the data from the excel file to this already existing entity);


5. In the for each loop I set the record LIST the name given to Excel to Record List widget. 


6. Now the problem is in the assign... how can we assign the value existing in the xlsx file to the right attribute in the entity? 

the left side of the assign will be of course the LOCAL Variable specific to a certain attribute. I am not sure about the RIGHT side of the assign (is it direct to put the structure attribute?)


7. I will use the UpdateEntity action (we need to add more lines to the entity, not erase anything that is already present in the entity) - after the assign of course. 


Afterwards I will create a timer to run this user action when I publish the eSpace. 

To feed the attribute with NULL values, I will add to the upload action (after the for each loop) an aggregate to join this entity with the entity with the info needed to feed the null values. If there is a better way let me know. Thanks. 



Hi,

You can do the assign to the entity in 2 ways in the latest versions of Outsystems. Or you attribute a structure to it and do the mapping or you attribute 1 field at a time. 

If you want to keep the values already present on the entity you should set 1 attribute at the time using a if(check if entity has values, keep values of entity, add value of excel). 

Timers that run when publish should be used to bootstrap and have a condition in the beginning that don't let them run more than 1 time.

If this isn't enough help share with us what u already have so we can help you better

Regards,

Marcelo

Yep, I forgot to add that condition inside the loop. It is already done. 


Nevertheless, I am getting this error when I try to do the bootstrap: 

"Excel read error in row 2: Column 'Idxxxxx' has an invalid type. Expected a 'Int32' but received a 'String'. "

This is the attribute that has no information.  It does not exist in the original EXCEL file but in the entity. I have added this new column in the excel.... So I have tried to populate it in the excel with random numbers (type: integer) but the entity attribute is an identifier type. How can I overcome this problem? 


unless I change the attribute type temporally to text  and then it will be possible to run... (after the bootstrap i could change to the original type as an identifier). If there is another way...

Hi,

You should use a structure on the ExcelToRecord and then assign the values of that structure to the entity. And leave that attribute that only exists on the enity empty.

Regards,

Marcelo

even if i keep the empty column in the excel... (with type integer set in the excel) it keeps to deliver the error message: "Excel read error in row 2: Column 'Idxxxxx' has an invalid type. Expected a 'Int32' but received a 'String'. ""




In the excel to Record you use the entity or a structure on the record definition? You should use a structure with the same attributes as the excel. You doing this? Can you show me the properties of the ExcelToRecord?

Regards,

Marcelo

In the excel to Record you use the entity or a structure on the record definition?

Structure. The attributes in structure are exactly the same as in the excel file and in the right order, of course.


You should use a structure with the same attributes as the excel. You doing this? 

Yep. 

see attached.


ps I think 6th point (first post) is clarified. Now the problem concerns about the identifier column... 


Solution

The problem that you are facing is that the attribute of the structure that is receiving the colum Idxxxxx is an int but sometimes this column is empty on the excel. Maybe you can change the attribute of the structure to text and check it before assign it to the entity.

Regards,

Marcelo

Solution