Hi Community,
I have been making the companies bookingsystem using Sharepoint and Powerapps.
Now, I'm trying to automate a part of it.
For instance, every new booking has an invoice number that has to be filled in.
This number has the following build up 2017XXXX (year + number of invoice).
However, not every number has to be in the administration (invoice 20170023 could be deleted).
Also the number of the invoice does not correspond with the ID (sometimes invoice 20170011 is created before 20170009).
So, what I want is the following:
When I want to create a new record, by using NewForm in Powerapps, I want the default text in DataCardValue "Invoice Number" to be the number of the last record + 1.
Last booking/record was 20170346, so when I create a new form it should (by default) say 20170347.
I already tried to work with the Last() function, but couldn't get it working.
Can someone help me with this?
Thanks a lot!
G.H.
Solved! Go to Solution.
You can try sorting the SP list by the invoice id descending, and take the First element.
If you've created your app using the "Start with your data" option, then you can get that value when selecting the 'Create new item' option:
NewForm(EditForm1); Navigate( EditScreen1, ScreenTransition.None, { isNewItem:true, defaultInvoiceId:Last( SortByColumns( SPListName, "InvoiceId", Descending)).InvoiceId })
And on the edit screen, you would update the Default property of the text input control that holds the invoice id (you first need to unlock the card in the Advanced pane in the right-hand side) to
If(isNewItem, defaultInvoiceId, Parent.Default)
You can try sorting the SP list by the invoice id descending, and take the First element.
If you've created your app using the "Start with your data" option, then you can get that value when selecting the 'Create new item' option:
NewForm(EditForm1); Navigate( EditScreen1, ScreenTransition.None, { isNewItem:true, defaultInvoiceId:Last( SortByColumns( SPListName, "InvoiceId", Descending)).InvoiceId })
And on the edit screen, you would update the Default property of the text input control that holds the invoice id (you first need to unlock the card in the Advanced pane in the right-hand side) to
If(isNewItem, defaultInvoiceId, Parent.Default)
Value(Last(ListName).ID)+1
Does this not work??
Thank you Delid4ve,
This was a straightforward solution.
This solves the first part for me.
However, it created a new problem.
Somehow, it says that the last item in the column is 20170514.
The actual last booking I made was with number 20170669.
Do you have any idea why it ignores the bookings after 20170514?
Thank you,
G.H.
The weird thing is that the app wasn't even created during that time.
I was already at approx. booking number 20170615 when I created the app.
Do you think the refresh will still fix the situation?
User | Count |
---|---|
162 | |
96 | |
76 | |
72 | |
59 |
User | Count |
---|---|
213 | |
166 | |
97 | |
95 | |
77 |