cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kristinegriba
Advocate I
Advocate I

Variable Keeps Resetting

I have a variable set in the "OnStart" action of my app, Set(varProjNum, 0).

 

I then use this to create a counter to help me generate project numbers on my 'new project' screen.

 

It all works very well allowing me to incrementally add new projects and new project numbers, as many as I need. Unfortunately, when I start work again the next morning and launch my app, varProjNum resets to 0, and thus my project numbers  start all over again 😞

 

Why?

 

I would prefer my project numbers continue on from wherever I left off the last time I used my app... to continue counting from the last submitted project number. How do I accomplish this?

 

Thank you  in advance

 

Best,

Kristine

 

P.S. additional info: Upon submitting my new project information, I am patching that info into my Sharepoint list; I am not using collections.

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User
Super User

@kristinegriba 

The scope of a 'Set' variable is per session - that's why it resets when you restart your app.

To work around this, you could retrieve the last project number from SharePoint in the OnStart of your app.

Set(
    varProjectNum,
    First(SortByColumns(SharePointList, ProjectNum, Descending).ProjectNum
)

View solution in original post

3 REPLIES 3
timl
Super User
Super User

@kristinegriba 

The scope of a 'Set' variable is per session - that's why it resets when you restart your app.

To work around this, you could retrieve the last project number from SharePoint in the OnStart of your app.

Set(
    varProjectNum,
    First(SortByColumns(SharePointList, ProjectNum, Descending).ProjectNum
)
kristinegriba
Advocate I
Advocate I

Thanks, timl... I will give that a try when I get home from work this evening, and let you know if that worked for me..

@timl So I tried your suggestion and it didn't quite work exactly as you had it there, but I did manage to get it to work by using the concept of grabbing the last stored number to generate the new project number. thanks!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,110)