cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
David8
Resolver I
Resolver I

Counter Issue

I used a solution posted Matthew Devaney to set up a counter that assigns a unique number for each ticket request a customer submits through my app, and it works perfectly. The reason I like it, is that I can always start at number one, and this counter let's me start wherever I want. But recently, I came across a problem that has not come up before. When a customer submits a ticket and gets a number assigned, if that same individual immediately submits a second request, the same number is getting assigned to a different request instead of incrementing to the next number. This has occurred twice already but only when the same person submits a request one after the other. Any way, I can't seem to figure out where I'm going wrong. Here is my code.

 

Set(startingIdNumber, 1281); This was the original starting number.
Set(currentValue, First(Sort(Counter, Value, Descending)).Value);
Set(nextIdNumber, If(IsBlank(currentValue), startingIdNumber, currentValue + 1));
 
This patches to a Counter SharePoint list.
Patch(
Counter,
Defaults(Counter),
{Title: TXProjectName.Text},
{Value: nextIdNumber}
 
SubmitForm('FM-Customer');
ResetForm('FM-Customer');
);

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

You are always very helpful, Randy, and it is much appreciated. Thank you.

 

View solution in original post

4 REPLIES 4
zmansuri
Super User
Super User

Set(startingIdNumber, 1281);
Set(currentValue, First(Sort(CounterValue, Descending)).Value);
Set(nextIdNumber, If(IsBlank(currentValue), startingIdNumber, currentValue + 1));
 
Where is this above code written? App Onstart property?

It is using the submit button's Onselect property. I don't have anything in the App Onstart property..

 

RandyHayes
Super User
Super User

@David8 

Consider making the following changes.

 

In the OnSelect action of the button:  SubmitForm('FM-Customer');

 

In the OnSuccess action of the FM-Customer form:

With({_value: 
         Coalesce(
             First(Sort(Counter, Value, Descending)).Value,
             1281
         )
    },
    Collect(Counter,
        {Title: TXProjectName.Text,
         Value: _value
        }
    )
);

ResetForm('FM-Customer');
 
I hope this is helpful for you.
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

You are always very helpful, Randy, and it is much appreciated. Thank you.

 

View solution in original post

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,401)