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.
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.
Hi @nshaw75 ,
If you remove the code you added and only retained SubmitForm(Form1), does it still have an error after submitting?
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
@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})
@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 :
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
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.
Are you using patch to create new records into your SharePoint list? Can you share me the formula of your patch?
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 😐
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.