Hi,
I am expereincing a datatype error: "incompatible type. we can't evaluate your formula because the context variable types are incompatible with the types of values in other places in your app". Seems like it is related to resetting the original variabe to the return value from the Patch function, but i am not sure. Please help me!
I get a record from the datasource once the user login:
Set(gblAppUserSettings, LookUp(UserSettings, User.UserId = gblAppUser.UserId));
I update a "Show Pinyin" user setting through a toggle. Within the onSelect action, I have the following code:
Set(gblAppUserSettings, Patch(
UserSettings,
gblAppUserSettings,
{
ShowPinyin: If(
tglShowPinyin.Value = true,
'ShowPinyin (UserSettings)'.Yes,
'ShowPinyin (UserSettings)'.No
)
}
));
However, this is where i start getting all the errors related to the "gblAppUserSettings" type.


What i have tried:
1. I inspected the return value of the Patch function through the Variable view and both the old record and the new (updated) record have the same GUID id. Both these values are of type "record".
2. I set a placeholder value "Set(gblAppUserSettings, Defaults(UserSettings))" at the very beginning, doesn't work.
3. I rename "gblAppUserSettings" to "gblAppUserSettings1" in the onSelect function, and then change it back. The error goes away!! Everything works fine. I can update and run the app normally. But when i close the app and reopen it again, all the above errors come back : ( .... This is very weird...
Your help is much appreciated.