Plan 3: Memory-based Entry + Single Write on Exit
In App OnStart:
powerapps
Set(AppIdentifier, "App1");
Set(SessionData, Blank()); // Initialize session tracking
On Screen.OnVisible (Store in memory only):
powerapps
// Store entry data in memory - NO SharePoint write
Set(
SessionData,
{
EnterTime: Now(),
AppName: AppIdentifier,
ScreenName: App.ActiveScreen.Name,
Username: Left(User().Email, Find("@", User().Email) - 1),
ProjectID: If(IsBlank(YourSelectedProject), "None", YourSelectedProject.ID)
}
);
On Screen.OnHidden (Write complete log):
powerapps
// Single write with complete session data
If(
!IsBlank(SessionData),
Patch(
apps_text_log,
Defaults(apps_text_log),
{
linelog: Text(SessionData.EnterTime, "yyyy-mm-dd hh:mm:ss") & "," &
Text(Now(), "yyyy-mm-dd hh:mm:ss") & "," &
SessionData.AppName & "," &
SessionData.ScreenName & "," &
SessionData.Username & "," &
SessionData.ProjectID & "," &
Text(DateDiff(SessionData.EnterTime, Now(), Seconds))
}
);
Set(SessionData, Blank()); // Clear memory
);




