App.Formulas:
MyProfile = Office365Users.MyProfile(); MyEmail = MyProfile.Mail; MyData = Filter( UserData, 'Created By'.Email = MyEmail ); MyLocationFilterRecord = With({ ExistingRecord: LookUp( MyData, Title = "LocationFilter" ), TargetOfficeLocation: "OfficeLocation|" & MyProfile.OfficeLocation }, If(IsBlank(ExistingRecord), Patch( Defaults(UserData), { Title: "LocationFilter", Value: LookUp( Metadata, Title=TargetOfficeLocation, Data ) } ), ExistingRecord ) )
Then in my StartScreen .OnVisible:
Patch(
UserData,
MyLocationFilterRecord,
{}
)
What I want is to create a new record unless a record already exists. What I get is a new record even when a record already exists.
All in all Named Formulas is a great concept that would simplify app code, but they don't seem to work. It seems like at times the named formulas are not evaluated when one would expect them to be. Any time there is a reference to a named formula, the promise is that it would be evaluated at that time. That does not seem to be the case. For now I have to keep using App.OnStart or a Loading Screen .OnVisible