I am creating a purchase order app. I need the title of the P.O. to look like this "LOG-AA-0003" (AA being the user's initials). I need the numbers to be successive based on the user. so if John Doe were to start a P.O., his P.O.'s number would be based off of his last entry, not the latest entry (I hope that makes sense). At any rate, I don't have a whole ton of users that will be using this so I am okay with having to code everyone in if that's how it must be. This is the code I have so far:
"LOG-" & If(User().FullName = "Alexander Salamander", "AS", "NO") & "-"
I have no idea how to get a succesive number. I have the data sitting on one excel sheet. One table has the P.O. information like the date and vendor. The other table is strictly for items. I did this because people might have multiple items for one P.O. My idea, in order to keep them under the same P.O., was to have the first table's P.O. number fill in the "title" spot for each item so the P.O remained the same for the items they order on the second table.
Another user suggested this:
Hi @Salamander94 ,
Could you please share a bit more about the data source you used in your app? Is it a SP List?
Could you please share a bit more about the data structure of your data source?
Further, do you want to generate the Title field based on the users initials then a successive number?
Based on the needs that you mentioned, I have made a test on my side, please take a try with the following workaround:
Unlock the Title Data card within the Edit form, set the Default property of the Text Input box to following:
"LOG-"& Left(First(Split(CurrentUser," ")).Result,1) & Left(Last(Split(CurrentUser," ")).Result,1) & "-" & If( Len(Text(Value(Last(Split( Last(Filter('20190611_case8', "LOG-"&Left(First(Split(CurrentUser," ")).Result,1) & Left(Last(Split(CurrentUser," ")).Result,1) in Title)).Title, "-" )).Result)+1))=1, "000"&Value(Last(Split(Last(Filter('20190611_case8', "LOG-"&Left(First(Split(CurrentUser," ")).Result,1) & Left(Last(Split(CurrentUser," ")).Result,1) in Title)).Title, "-" )).Result)+1, Len(Text(Value(Last(Split( Last(Filter('20190611_case8', "LOG-"&Left(First(Split(CurrentUser," ")).Result,1) & Left(Last(Split(CurrentUser," ")).Result,1) in Title)).Title, "-" )).Result)+1))=2, "00"&Value(Last(Split(Last(Filter('20190611_case8', "LOG-"&Left(First(Split(CurrentUser," ")).Result,1) & Left(Last(Split(CurrentUser," ")).Result,1) in Title)).Title, "-" )).Result)+1, Len(Text(Value(Last(Split( Last(Filter('20190611_case8', "LOG-"&Left(First(Split(CurrentUser," ")).Result,1) & Left(Last(Split(CurrentUser," ")).Result,1) in Title)).Title, "-" )).Result)+1))=3, "0"&Value(Last(Split(Last(Filter('20190611_case8', "LOG-"&Left(First(Split(CurrentUser," ")).Result,1) & Left(Last(Split(CurrentUser," ")).Result,1) in Title)).Title, "-" )).Result)+1, Value(Last(Split(Last(Filter('20190611_case8', "LOG-"&Left(First(Split(CurrentUser," ")).Result,1) & Left(Last(Split(CurrentUser," ")).Result,1) in Title)).Title, "-" )).Result)+1 )
Note: The CurrentUser is a variable in my app, which used to store the Display Name of the current sign in user. The '20190611_case8' represents my SP List data source.
On your side, you should type:
If( EditForm1.Mode = FormMode.New, "LOG-"&
Left(First(Split(User().FullName," ")).Result,1) & Left(Last(Split(User().FullName," ")).Result,1) & "-" &
If(
Len(Text(Value(Last(Split(Last(Filter('YourDataSource', "LOG-"&Left(First(Split(User().FullName," ")).Result,1) & Left(Last(Split(User().FullName," ")).Result,1) in Title)).Title, "-" )).Result)+1)) = 1,
"000"&Value(Last(Split(Last(Filter('YourDataSource', "LOG-"&Left(First(Split(User().FullName," ")).Result,1) & Left(Last(Split(User().FullName," ")).Result,1) in Title)).Title, "-" )).Result) + 1,
Len(Text(Value(Last(Split( Last(Filter('YourDataSource', "LOG-"&Left(First(Split(User().FullName," ")).Result,1) & Left(Last(Split(User().FullName," ")).Result,1) in Title)).Title, "-" )).Result)+1)) = 2,
"00"&Value(Last(Split(Last(Filter('YourDataSource', "LOG-"&Left(First(Split(User().FullName," ")).Result,1) & Left(Last(Split(User().FullName," ")).Result,1) in Title)).Title, "-" )).Result) + 1,
Len(Text(Value(Last(Split( Last(Filter('YourDataSource', "LOG-"&Left(First(Split(User().FullName," ")).Result,1) & Left(Last(Split(User().FullName," ")).Result,1) in Title)).Title, "-" )).Result)+1)) = 3,
"0"&Value(Last(Split(Last(Filter('YourDataSource', "LOG-"&Left(First(Split(User().FullName," ")).Result,1) & Left(Last(Split(User().FullName," ")).Result,1) in Title)).Title, "-" )).Result) + 1,
Value(Last(Split(Last(Filter('YourDataSource', "LOG-"&Left(First(Split(User().FullName," ")).Result,1) & Left(Last(Split(User().FullName," ")).Result,1) in Title)).Title, "-" )).Result) + 1
), Parent.Default )
Note: The Title column represents the Title column in your data source, which used to store the generated title value.
Please consider take a try with above solution, then check if the issue is solved.
Best regards,
Solved! Go to Solution.
Yes, if you were using a unified numeration, that would be an issue. But in this case there is a unique aspect to it that would provide autonomy. One caveat to this though, the proposed solution is based on user initials, one could surmise that there is a very real potential that there are two users with the same initials - in which case I would say something more unique to that user would be needed rather than initials.
But back to your point, I still don't believe that would be a concern - the onvisible and until saved aspect - because the only thing that is calculated in the variable is the "LOG-xx" (xx is user initials). The actual sequence number based on that is determined in the Default property of the datacard for a New record. The variable never changes nor needs to change, it is only put into its own separate calculation so that it is not in the Filter function - in which case PowerApps will evaluate it during the filter and trigger a delegation issue.
Randy, as always, you the man! Thanks for the help yet again!
User | Count |
---|---|
183 | |
124 | |
88 | |
45 | |
42 |
User | Count |
---|---|
248 | |
159 | |
127 | |
78 | |
73 |