Convert an entity into a DataTable

I would like to know if there is a way to transform an entity into a table. To provide context, I have defined “entities” in UiPath using UiPath.DataFabric on the web. Subsequently, I imported these entities into UiPath Studio. Through the “Manage Entities” button, I would like to convert an entity into a DataTable to later save it in an Excel file. What approach would you recommend?

@Matias_Clemente.Arg,

Try using Collection to Data Table activity for this.

1 Like

Error ERROR Validation Error BC30512: Option Strict On does not allow implicit conversions from ‘AvanceDelRobot’ to ‘ICollection(Of Object)’. The selected value is incompatible with the property type. Framework/InitAllSettings.xaml

Hi @Matias_Clemente.Arg ,

Thank you for sharing the screenshot and the error description. It’s helping to get your issue..

You are getting this error because there is a compatibility issue.

The collection to DataTable activity is expecting a collection of object.

To fix this issue in use : ent_Avance.Cast(Of Object).ToList() in place of ent_Avance. in collection(Coleccion) field

Also don’t forget to set the TypeArgument of the Collection to DataTable activity to Object.

Please mark this as a solution if it solves your issue.

All the best.

1 Like

@Matias_Clemente.Arg

  1. First you need to use a get record or query activities to get the entity records
  2. then the output of that would be a list of records and it has a limit of 1000 records if the entity data exceeds it you need to use a loop and then skip and get next set of records
  3. Now once these two are done that is where you can use linq or loop to convert the list of entity records into a datatable as you need

Hope this helps

cheers

1 Like
  1. Use the Get Entities activity

This retrieves a list of entity records from Data Service.

Output: List

  1. Convert the List to a DataTable:

Use an Invoke Method or Assign activity with LINQ or a loop to build a DataTable.


VB code:

Assign dt = New DataTable()
For Each prop In entityList(0).GetType().GetProperties()
dt.Columns.Add(prop.Name)
Next

For Each entity In entityList
row = dt.NewRow()
For Each prop In entity.GetType().GetProperties()
row(prop.Name) = prop.GetValue(entity)
Next
dt.Rows.Add(row)
Next

1 Like

Hi @Matias_Clemente.Arg
Use Query Entity Records to get data, then loop through the list or use LINQ to convert it to DataTable and write to Excel.

For more:-

Happy Automation

1 Like

Hello everyone (@ashokkarale, @Aleem_Khan, @Tapas_Kumar_Pattnaik, @Anil_G), I truly appreciate your responses and always strive to learn from them. I will investigate each of your approaches and provide feedback on the outcomes. Best regards.

2 Likes