# Having trouble loading data table from config reference (UE4.27)

**URL:** <https://forums.unrealengine.com/t/having-trouble-loading-data-table-from-config-reference-ue4-27/1602779>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, config, CPP, question\
**Created:** [January 9, 2024, 9:48pm UTC](https://forums.unrealengine.com/t/having-trouble-loading-data-table-from-config-reference-ue4-27/1602779 "2024-01-09T21:48:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hairy\_Cabbage](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hairy_cabbage/32/474160_2.png) [@Hairy\_Cabbage](https://forums.unrealengine.com/u/Hairy_Cabbage)\
**Post date:** [January 9, 2024, 9:48pm UTC](https://forums.unrealengine.com/t/having-trouble-loading-data-table-from-config-reference-ue4-27/1602779/1 "2024-01-09T21:48:44Z")

</div>

So my goal was to set up a system where I could quickly change up level sets for my various game modes in project settings during testing.

I made this class to store 3 composite tables in project settings:

```auto
UCLASS(Config = Game, defaultconfig, meta = (DisplayName="Level Settings"))
class MARBLE0001_API ULevelSettings : public UDeveloperSettings
{
	GENERATED_BODY()

public:

    UPROPERTY(Config, EditAnywhere, BlueprintReadOnly)
    TSoftObjectPtr<UCompositeDataTable> singlePlayerLevels;

    UPROPERTY(Config, EditAnywhere, BlueprintReadOnly)
    TSoftObjectPtr<UCompositeDataTable> arcadePlaylists;

    UPROPERTY(Config, EditAnywhere, BlueprintReadOnly)
    TSoftObjectPtr<UCompositeDataTable> challengeLevels;
	
};

```

I then wrote some functions to read these table references:

.h

```auto
UCLASS()
class MARBLE0001_API ULevelInfoFunctions : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

    UFUNCTION(BlueprintPure)
    static UCompositeDataTable* getSinglePlayerLevels();

    UFUNCTION(BlueprintPure)
    static UCompositeDataTable* getArcadePlaylists();

    UFUNCTION(BlueprintPure)
    static UCompositeDataTable* getChallengeLevels();

};

```

.cpp

```auto
UCompositeDataTable* ULevelInfoFunctions::getSinglePlayerLevels()
{
    const ULevelSettings* LevelSettings = GetDefault<ULevelSettings>();
    return LevelSettings ? LevelSettings->singlePlayerLevels.Get() : nullptr;
}

UCompositeDataTable* ULevelInfoFunctions::getArcadePlaylists()
{
    const ULevelSettings* LevelSettings = GetDefault<ULevelSettings>();
    return LevelSettings ? LevelSettings->arcadePlaylists.Get() : nullptr;
}

UCompositeDataTable* ULevelInfoFunctions::getChallengeLevels()
{
    const ULevelSettings* LevelSettings = GetDefault<ULevelSettings>();
    return LevelSettings ? LevelSettings->challengeLevels.Get() : nullptr;
}

```

The issue im having is that when I load the project, only the first (single player levels) data table loads. The others return null UNLESS i re-add the table reference in the project settings, and then they will start working as expected.

Im really confused as to why this is happening, and im hoping it is something that i can fix since its very annoying having to clear and re-set the datatables in the project settings each time I load the project.

Its probably also worth mentioning that I did also try UDataTable also, since the bottom two don’t actually need to be composite, but I thought maybe the issue was that data tables wouldn’t work so I changed them all to comp tables.

The config file looks like this:

```auto
[/Script/Marble0001.LevelSettings]
singlePlayerLevels=/Game/Data/Data_LostMarbles/Levels/CData_SinglePlayer.CData_SinglePlayer
arcadePlaylists=/Game/Data/Data_LostMarbles/Levels/CData_ArcadePlaylists.CData_ArcadePlaylists
challengeLevels=/Game/Data/Data_LostMarbles/Levels/CData_Challenges.CData_Challenges

```

I have tried clearing everything like saved and intermediate folders etc, but none of that seemed to work. I appreciate if anyone has any insight into this issue, thanks!

---

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [January 9, 2024, 9:53pm UTC](https://forums.unrealengine.com/t/having-trouble-loading-data-table-from-config-reference-ue4-27/1602779/2 "2024-01-09T21:53:03Z")

</div>

are you sure they are U_Composite_DataTables ?  
im using the more generic UDataTable\*

probably your problem is that the tsoftobjptr is not loaded.  
i do

```auto

UDataTable* const Chars = SysSettings->Characters.LoadSynchronous();

```

but yeah, the regular loading caveats.

---

<div class="post-metadata">

**Author:** ![Hairy\_Cabbage](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hairy_cabbage/32/474160_2.png) [@Hairy\_Cabbage](https://forums.unrealengine.com/u/Hairy_Cabbage)\
**Post date:** [January 9, 2024, 9:56pm UTC](https://forums.unrealengine.com/t/having-trouble-loading-data-table-from-config-reference-ue4-27/1602779/3 "2024-01-09T21:56:38Z")

</div>

I was actually just making an edit to my post when you replied. Originally the arcade and challenge tables were actually just UDataTables, but since the comp table was the only one working, I decided to try changing them all to comps to see if that fixed it, but it didn’t.

Id like to avoid loading synchronously since it would require a lot of reworking, so a blocking load is best for my use in this instance.

---

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [January 9, 2024, 10:00pm UTC](https://forums.unrealengine.com/t/having-trouble-loading-data-table-from-config-reference-ue4-27/1602779/4 "2024-01-09T22:00:52Z")

</div>

> [@Hairy\_Cabbage](#):
>
> Id like to avoid loading synchronously

everyone does it different, hence my “usual loading caveats”.  
but afaik anyway you load it is fine.  
also afaik the tsoftobjptr wont keep a ref to it. so it could be unloaded if not used, but i dont know much about that.

good luck i hope that fixes it.

---

<div class="post-metadata">

**Author:** ![Hairy\_Cabbage](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hairy_cabbage/32/474160_2.png) [@Hairy\_Cabbage](https://forums.unrealengine.com/u/Hairy_Cabbage)\
**Post date:** [January 10, 2024, 2:59pm UTC](https://forums.unrealengine.com/t/having-trouble-loading-data-table-from-config-reference-ue4-27/1602779/5 "2024-01-10T14:59:28Z")

</div>

> [@nande](#):
>
> `LoadSynchronous()`

So I changed my functions to the following and it seems to have solved the issue:

```auto
UCompositeDataTable* ULevelInfoFunctions::getSinglePlayerLevels()
{
    return GetDefault<ULevelSettings>()->singlePlayerLevels.LoadSynchronous();
}

UCompositeDataTable* ULevelInfoFunctions::getArcadePlaylists()
{
    return GetDefault<ULevelSettings>()->arcadePlaylists.LoadSynchronous();
}

UCompositeDataTable* ULevelInfoFunctions::getChallengeLevels()
{
    return GetDefault<ULevelSettings>()->challengeLevels.LoadSynchronous();
}

```

Thanks nande!

---

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [January 18, 2024, 4:21am UTC](https://forums.unrealengine.com/t/having-trouble-loading-data-table-from-config-reference-ue4-27/1602779/6 "2024-01-18T04:21:21Z")

</div>

im so happy it worked/helped! Well done 🙂

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [February 17, 2024, 4:22am UTC](https://forums.unrealengine.com/t/having-trouble-loading-data-table-from-config-reference-ue4-27/1602779/7 "2024-02-17T04:22:04Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
