Export csv (Data From Server Action)

Hello Community!

I need help with export CSV from a Server Action. 

I´ am following the explanation for export CSV from this forum:

https://www.outsystems.com/forums/discussion/60436/export-aggregate-data-in-csv-or-txt/

But I am having trouble getting the correct result with my sample data. That's because I'm looking for data from a server action. (Result) I did several tests, but I still haven't figured out what I need to do for the file to come with the information, it has been without data.

To contextualize:

I have a serve action, called "DepartmentEmployee", in it I filter the entities and present as a result a list (structure).

Does this filter work? Yes, I did an Excel export from the result of this server action and got the correct result.

I also did a test on another screen by inserting in the server action of the CSVUtil extension "ExportRecordList2CSV" information directly from an aggregate and I got the correct result.



My problem is when I seek this information from the result of my server action the export comes without data ... what could I do to export in CSV the result of my server action?

I attached the "Sample Test"OML. 

Best Regards, 

Jessica Marques.

SampleTests.oml


Hi Jessica,

my bad, after using a list of records I had also experimented with a list of an entity to compare it to a list of structure and a list of record.

So please, make sure it's the record list used in the ToObject :



Hi Jessica,

I have made some changes in server action ExportCSVWithExtension and able to download the data in CSV. 

Please refer attached OML and CSV file.

Thanks & Kind Regards,

Sachin

SampleTestsSachin.oml

Report.csv attached.

Report.csv

Hi  Sachin Waghmare

Thanks for the help. But I have some problems to undestand the changes and make the export csv with all attibute from Sample.Employee and Sample. Department. 

As I understand it, the way you did it should bring all the attributes of these entities? Because when I take the test, the result I get is this:

I would like to see this information, but in CSV. 

What do you think that I need to do?

Regards, 

Jessica Marques. 

Hi Jessica,

Have you seen the report.csv file which I have attached in my previous reply which was generated through the OML? It have all the attributes from both Department and Employee.

Thanks & Kind Regards,

Sachin


Hello, Sachin

Thanks for your attention,I saw the file report.csv you sent, but when I open the file it appears as follows: (sorry I forgot to comment earlier).

Kind Regards, 

Jessica. 

Hi Jessica,

I think the object you pass into ExportRecordListToCSV needs to be a record list, i.e. literally a list of records.  And nothing else like a list of structure or a list of entity.

See attached oml, I first transferred the data in your ResultPreparation List to a Department, Employee Record List, and that works fine.


Dorine

SampleTestsWithRealRecordList.oml

Hello Dorine Boudry

Thanks for the help. It makes perfect sense and I tried to do something like that, but I was unsuccessful.In the OML you sent me, I couldn't get results when I exported csv. What could I do to make the information appear correctly?

Regards, 

Jessica Marques.


Hi Jessica,

my bad, after using a list of records I had also experimented with a list of an entity to compare it to a list of structure and a list of record.

So please, make sure it's the record list used in the ToObject :



Hello,

Thanks for the help, Now it works perfectly!

Best Regards, 

Jessica. 

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