cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Vinoth1_
Helper IV
Helper IV

Auto generate order number when click the + buttom

Hi All,

 

I am in the process of developing poserapps customized form for sharepoint list.

 

the need is in sharepoint list whenever i click the + symbol below pasutijuma Nr, i was expecting it create an auto generated order no starting from AR0001,

 

then when i open new task on list and press the +button it should generate AR0002 and so on.

 

but at the moment donot know how to do it.

 

Capture22.JPG

 

Capture24.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @Vinoth1_ :

Please try this solution:

Find the record with the highest order number in the data source, get its number and +1

1\Set the "+"'s OnSetect proeprty to:

 

Set(
    Var, /*Var is my custom variable*/
    "AR" & Text(
        Value(
            Right(
                First(
                    Sort(
                        Filter(
                            YourDateSource,
                            StartsWith(Title,"AR")   /*Title is the name of the field used to store the order number, yours may be Pas...*/
                        ),/*Get all records with numbers starting with AR*/
                        Value(
                            Right(
                                Title,
                                4
                            )
                        ),/*The root intercepts the last four digits of the order number and formats it as a number*/
                        Descending/*Sort according to the numerical value of the last four digits of the order number*/
                    )
                ).Title,
                4
            )
        ) + 1,/*Get the largest order number, add his value +1*/
        "[$-en]0000"
    )
);
Reset(TextInput1)/*Reset the textinput control*/

 

2\Set the TextInput1's Default property to:

 

Var

 

50.gif

Best Regards,

Bof

 

View solution in original post

5 REPLIES 5
Vinoth1_
Helper IV
Helper IV

any help with formular are highly appreciated.

v-bofeng-msft
Community Support
Community Support

Hi @Vinoth1_ :

Please try this solution:

Find the record with the highest order number in the data source, get its number and +1

1\Set the "+"'s OnSetect proeprty to:

 

Set(
    Var, /*Var is my custom variable*/
    "AR" & Text(
        Value(
            Right(
                First(
                    Sort(
                        Filter(
                            YourDateSource,
                            StartsWith(Title,"AR")   /*Title is the name of the field used to store the order number, yours may be Pas...*/
                        ),/*Get all records with numbers starting with AR*/
                        Value(
                            Right(
                                Title,
                                4
                            )
                        ),/*The root intercepts the last four digits of the order number and formats it as a number*/
                        Descending/*Sort according to the numerical value of the last four digits of the order number*/
                    )
                ).Title,
                4
            )
        ) + 1,/*Get the largest order number, add his value +1*/
        "[$-en]0000"
    )
);
Reset(TextInput1)/*Reset the textinput control*/

 

2\Set the TextInput1's Default property to:

 

Var

 

50.gif

Best Regards,

Bof

 

View solution in original post

Hi @v-bofeng-msft ,

Thanks for help, i appreciate.

i used this formula on property & used Var on text input

Set(
    Var, 
    "AR" & Text(
        Value(
            Right(
                First(
                    Sort(
                        Filter(
                            'Aluminium order',
                            StartsWith('Pasūtījuma Nr',"AR")   
                        ),
                        Value(
                            Right(
                                'Pasūtījuma Nr',
                                4
                            )
                        ),
                        Descending
                    )
                ).'Pasūtījuma Nr',
                4
            )
        ) + 1,
        "[$-en]0000"
    )
);
Reset(DataCardValue12)

when i make a new item, the form already has this number before i press the + button

Capture.JPG

 

and when i make a new item next, it again has the same order no. Capture1.JPG

 

please can you tell me what went wrong here. what adjustment should i need to make.

Hi @Vinoth1_ :

The reason is that the value of the variable Var is not reset, it is retained until you add the record for the second time.

The solution is simple:

The key is to clear the value of the variable Var after submitting the record.

1\Set the SharePointIntegration's OnSave property to:

 

SubmitForm(SharePointForm1);Set(Var,"")

 

If you submit the record through a custom button, then you can put Set(Var,"") after the formula you submit the record.

2\Set the DateCardValue12's Default property to(This step is to increase the robustness of the app):

 

If(IsBlank(Parent.Default),Var)

 

58.gif

Best Regards,

Bof

 

Hi @v-bofeng-msft ,

 

Many thanks for help. Its working now.

Helpful resources

Announcements
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (43,009)