How to save DataTables at edit time from code?

I have a data table which I populate at edit time using:

MyDataTable->AddRow(MyStruct->ComponentTags[0], MyData);

and then I want to save it using something like:

UPackage::Save(MyDataTable->GetPackage(), MyDataTable, RF_Public | RF_Standalone, MyDataTable->GetPackage()->FileName.ToString().GetCharArray().GetData());

But because the MyData struct is apart of a specific class, and contains pointers to uproperties in that class, I can’t save it. I get this error:

Can't save MyDataTable.uasset: Graph is linked to object MyDataActor (Referenced because it is an archetype object) in external map

Any way I can get around this? I really don’t want to have to save my data to CSV or some other format and do a bunch of conversions if I can avoid it.

Thanks!

If there no other solution, you could try with bp with the Editor Utility to add rows to data table.
(min ue 5.3)

thanks!
I ended up just converting the MyStruct to a JSON string instead and storing that in the data table. I was also able to deserialize the struct from JSON back into the struct again so it worked out nicely

1 Like