I'm trying to write an application backed against a sharepoint list. When the application starts I need it to try to find a specific entry in that list and open a form in edit mode against that record. If the record doesn't exist I should instead open the form in new record mode and populate some default values. My record lookup criteria are based on the current user and a date.
I think I can see how to handle most of the flow using OnVisible events on the main form, but I'm drawing a blank on how to use PowerApps to select that initial record. I need to load it into a variable and set the datasource of my edit form to use that variable. If its not set then I can use the new record form instead (using an IF function) with my defaults stored in variables and the relevant fields bound to those variables.
So far I've tried the following, which seemed promising but when the form opens it shows as "no datasource provided", despite there being several records with display name "Test User". I've set the form's datasource to ppStartRecord:
Set(ppStartRecord, LookUp(WeeklyActivity, User.DisplayName="Test User"))
Any advice on how I can set a variable to a specific sharepoint list entry such that that variable can be the datasource for an edit form would be extremely welcome!
Thanks
Kevin