Hi Team,
Getting an Error while converting Dict to DataTable, PFA Image for Dict syntax and DT syntax as well… pls chekc what is the issue
The error is because you are using for each row in datatable & giving dictionary instead of datatable variable. You will have to use for each not for each row in datatable.
Follow these steps:
-
Use the Build DataTable activity to create a DataTable with columns “Key” (of type Integer) and “Value” (of type String).
-
Use a For Each activity to iterate through the dictionary.
-
Inside the loop, use the Add Data Row activity to add rows to the DataTable for each key-value pair.
Try this for converting dict to datatable
https://youtu.be/ZhrHEgWXXrk?si=WBTo33hvWQXB1M8g
Ref:
Hope this helps
@Devasaiprasad_Kakumanu
By using linQ we can convert Dict to datatable
Newtonsoft.Json.Linq.JArray.FromObject({Dict}).ToObject(of System.Data.Datatable)
@Devasaiprasad_Kakumanu
need to use For each activity as you are converting Dict to Datatable
Cheers!!
THis is the Method i am about to try but missed adding .ToObject(of System.data.datatable)
Thank you
HI,
Can you try the following sample?
dt = dict.Select(Function(kv) dt.LoadDataRow({kv.Key,kv.Value},False)).CopyToDataTable()
Sample
Sample20231124-5.zip (3.0 KB)
Regards,