cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kristinegriba
Helper I
Helper 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
Helper I
Helper 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
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (5,215)