Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Adding the next incremental number in the SharePoint list

(0) ShareShare
ReportReport
Posted on by 363

Apologies as I am certain this has been asked before, or a similar question at least.

 

I am creating an list of all ongoing projects. The projects will be initiated by a Power App form being completed. Each project will have it's very own Legacy Number created from the following :

 

{Site} - {area code} {next number on SP List}. eg LNDOF1234 would indicate the London Site Office Project #1234

 

The site & area code is a code which will be based on the return from a Form in Power Apps, the number from the SharePoint list must be a unique value and running incrementally. The Power Apps return will originally be the full wording and I would want to abbreviate them into a code.

  • nshaw75 Profile Picture
    nshaw75 363 on at
    Re: Adding the next incremental number in the SharePoint list

    @Adrian_Celis 

    Thanks again for the help. I have been told to keep the Form & flow as it is. I have been spending too much time trying to get the first part (Creating the correct legacy name) working , before I even get to the more complicated part of creating the new SP site.

     

    Thanks again for taking the time to help.

     

  • Adrian_Celis Profile Picture
    Adrian_Celis 1,652 on at
    Re: Adding the next incremental number in the SharePoint list

    Hi @nshaw75 ,

    If you remove the code you added and only retained SubmitForm(Form1), does it still have an error after submitting?

  • nshaw75 Profile Picture
    nshaw75 363 on at
    Re: Adding the next incremental number in the SharePoint list

    Hi @Adrian_Celis . I have popped the code in and I am now getting a network error: Requested operation is invalid, when trying to submit the form, the red line in the formula bar is under the first part -  SubmitForm(Form1)

    which I am finding strange

     

  • Adrian_Celis Profile Picture
    Adrian_Celis 1,652 on at
    Re: Adding the next incremental number in the SharePoint list

    @nshaw75 Oh so you only added LDS as a prefix, so that means your ref number will be LDS1

    Therefore you should change the 6 into 4 because it should get the 4th character. Try

     

    SubmitForm(Form1);Navigate(Screen1);Patch('Project Tracker list - PowerApp',Form1.LastSubmit,{LegacyName:"LDS"& Coalesce(Value(Mid(First(Sort('Project Tracker list - PowerApp',LegacyName,SortOrder.Descending)).LegacyName,4)),0)+1})
  • nshaw75 Profile Picture
    nshaw75 363 on at
    Re: Adding the next incremental number in the SharePoint list

    @Adrian_Celis  Thanks for the help.

     

    I have noticed that some of the columns have slightly different names, so i have adjusted the formula accordingly. 
    My formula for the OnSelect property is as follows : 

    SubmitForm(Form1);Navigate(Screen1);Patch('Project Tracker list - PowerApp',Form1.LastSubmit,{LegacyName:"LDS"&Value(Mid(First(Sort('Project Tracker list - PowerApp',LegacyName,SortOrder.Descending)).LegacyName,6))+1})

    I have no errors and it has submitted the form, although the legacy number hasn't been filled in.
  • Adrian_Celis Profile Picture
    Adrian_Celis 1,652 on at
    Re: Adding the next incremental number in the SharePoint list

    Hi @nshaw75 

    Alright. understood. So you have to put this code at the bottom of the SubmitForm(Form1)

     

     

    Patch(YourSPListHere,Form1.LastSubmit,
    {
    LegacyNumber: Site & AreaCode & Value(Mid(First(Sort(YourSPListHere,LegacyNumber,SortOrder.Descending)).LegacyNumber,6))+1
    })

     

     

    Replace YourSPListHere with the name of your SP List.

    Make sure to have a column named LegacyNumber as a signle line text in the SP List.

    Replace Site with the Site number

    Replace AreaCode with the Area Code

  • nshaw75 Profile Picture
    nshaw75 363 on at
    Re: Adding the next incremental number in the SharePoint list

    Hi @Adrian_Celis 

    Sorry I am a bit of a noob and have just been using a form which is connected to the SharePoint list and when I hit the button I use the SubmitForm(Form1) command to populate the list. 

  • Adrian_Celis Profile Picture
    Adrian_Celis 1,652 on at
    Re: Adding the next incremental number in the SharePoint list

    @nshaw75 

    Are you using patch to create new records into your SharePoint list? Can you share me the formula of your patch?

     

  • nshaw75 Profile Picture
    nshaw75 363 on at
    Re: Adding the next incremental number in the SharePoint list

    Thanks guys for helping out. @Adrian_Celis I am lost as to where I would put the formula into. I have set my sharepoint list up into descending order but I get stuck around that pont 😐

  • opticshrew Profile Picture
    opticshrew 193 on at
    Re: Adding the next incremental number in the SharePoint list

    I'd tackle this slightly differently.

     

    I'd have your form submit into the list, then use the Form.LastSubmit value to re-submit and you can then use the item id in the new id.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,567

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,907

Leaderboard