Getting a UDataTable from a UProperty

Hi,

I have an Actor Blueprint that defines a UDataTable that I need to access from C++.

I’m able to find and get the corresponding UProperty. A call to GetCppType() returns “UDataTable”.

I’m using the following code to get the UDataTable

UProperty* lProperty = lActor->GetClass()->FindPropertyByName("MyTable");
 
if (lProperty)
{
      UDataTable *lTest = lProperty->ContainerPtrToValuePtr<UDataTable>(lActor);
lTest->GetColumnTitles(); //crash
}

How can I get that UDataTable back?

Thanks

Just in case this is useful for somebody else, this is how you can do it

UProperty* lProperty = lActor->GetClass()->FindPropertyByName("MyTable");
UDataTable *lReturnDataTableVal = nullptr;

if (lProperty)
{
	UObjectProperty *lProp = Cast<UObjectProperty>(lProperty);
	lReturnDataTableVal = Cast<UDataTable>(lProp->GetPropertyValue_InContainer(lActor));
}