cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Harpreet_Tohra
Helper II
Helper II

Creating process Id starts from 000001

Hi I am trying to create  6 digit unique autoincrement  Process Id starting from 000001 to.... In power canvas app on create button and save it to SharePoint list. On create button it should check sharepoint last ID and auto increment it by 1 and show it on form and then update new on create button of form. But unfortunately it is showing 1 instead of 0000001 ..........

Can anybody plz help me to resolve this????

Thanks in advance 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Harpreet_Tohra 

We need to wrap First(Sort(... in Text( to convert it to a text value that can be concatenated.  Try this

 

 

With(
    {
        newID: Right(
            Concatenate(
                "000000",
                Text(
                    First(
                        Sort(
                            'SRD data',
                            'Process ID',
                            Descending
                        )
                    ).'Process ID' + 1,
                    "######"
                )
            ),
            6
        )
    },
    If(
        IsBlank(Parent.Default),
        newID,
        Parent.Default
    )
)

 

 

Or get rid of the Concatenate and just use

 

With(
    {
      newID: Right(
                   "000000" & First(
                                     Sort(
                                          'SRD data','Process ID',Descending
                                      )
                               ).'Process ID' + 1,
                     6
               )
    },
    If(
        IsBlank(Parent.Default),
        newID,
        Parent.Default
    )
)

 

If the form is New, Parent.Default will be blank.  This formula can be used for the Default value of a textbox control in the 'Process ID' card or as the Update property of the card.  I would either hide this card or make it disabled so users can't change it. 

 

View solution in original post

4 REPLIES 4
Drrickryp
Super User
Super User

Right(Concatenate("0000000", First(Sort(SPlist,ID,Descending)).ID+1),6)

Capture.PNG

Hi @Drrickryp  Thanks for Replying.

I tried this but unfortunately it is giving me some error. It would be great if you could help me to solve this.

If(Form1.Mode=FormMode.New,Right(Concatenate("000000",First(Sort('SRD data','Process ID',Descending)).'Process ID'+1),6))
Getting error on Concatenate and First in the code.

Thanks in advance

Hi @Harpreet_Tohra 

We need to wrap First(Sort(... in Text( to convert it to a text value that can be concatenated.  Try this

 

 

With(
    {
        newID: Right(
            Concatenate(
                "000000",
                Text(
                    First(
                        Sort(
                            'SRD data',
                            'Process ID',
                            Descending
                        )
                    ).'Process ID' + 1,
                    "######"
                )
            ),
            6
        )
    },
    If(
        IsBlank(Parent.Default),
        newID,
        Parent.Default
    )
)

 

 

Or get rid of the Concatenate and just use

 

With(
    {
      newID: Right(
                   "000000" & First(
                                     Sort(
                                          'SRD data','Process ID',Descending
                                      )
                               ).'Process ID' + 1,
                     6
               )
    },
    If(
        IsBlank(Parent.Default),
        newID,
        Parent.Default
    )
)

 

If the form is New, Parent.Default will be blank.  This formula can be used for the Default value of a textbox control in the 'Process ID' card or as the Update property of the card.  I would either hide this card or make it disabled so users can't change it. 

 

@Drrickryp It worked. Thanks Sir

Helpful resources

Announcements
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.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,554)