web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Create Unique Customer ID
Power Apps
Answered

Create Unique Customer ID

(0) ShareShare
ReportReport
Posted on by 44

I want to generate a unique customer id

 

The ID is XXXTRYYYYY

 

XXXX = Lookup of a counter + one

YYYY = Current year

 

Set(VarNextID,LookUp(TRIAMANT_TELLERS, Application="TriamantERP",CustomerID)+1);
Set(VarCurrentYear,Year(Now()));

 

I miss the VarNextCustomerID

This does not work 

Set(VarNextCustomerID, Concatenate(VarNextID,"TR",VarCurrentYear)); 

 

 

 

 

 

Categories:
  • eka24 Profile Picture
    20,925 on at

    Can you show a sample of your table

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Djack 

    Your formula is flawed.

     

     

    LookUp(TRIAMANT_TELLERS, Application="TriamantERP",CustomerID)+1) should be
    First(Sort(TTRIAMANT_TELLERS,CustomerID,Descending)).CustomerID+1)

     

     

    First(Sort( is used because Last() and Max() functions are not delegatable and will give incorrect results once the Items limit is exceeded.  First(Sort( will work no matter how many items are in the table.  Also, I am assuming that CustomerID is a number not a text value. 

  • Djack Profile Picture
    44 on at

    The table holds 3 fields

    Field 1 counter CustomerID

    Field 2 counter ContractID

    Field 3 counter AccountingID

     

    Nothing special

    The concatenate does not work ... gives error that something is wrong.

  • Djack Profile Picture
    44 on at

    But the concat is the issue here i get the error message that the formula is wrong.

     

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Djack 

    Concatenate requires text fields.  You will need to wrap numbers and dates in the Text() function.

     

    Concatenate(Text(First(Sort(TRIAMANT_TELLERS,customerID,Descending)).customerID+1),"TR",Text(Year(Now())))

     

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Djack :

    Could you tell me what CustomerID's data type is?(Set(VarNextID,LookUp(TRIAMANT_TELLERS, Application="TriamantERP",CustomerID)+1);)

    I assume CustomerID is a number filed.

    Firstly,let me explain why you encounted this problem.

    The Concatenate function can only concatenate strings but 'VarNextID'  and  VarCurrentYear are number.

    Secondly,I suggsest you try this code:

     

    Set(VarNextCustomerID, Concatenate(Text(VarNextID),"TR",Text(VarCurrentYear)))

     

    Or

     

    Set(VarNextCustomerID, VarNextID&"TR"&VarCurrentYear);

     

    Best Regards,

    Bof

     

  • Verified answer
    Djack Profile Picture
    44 on at

    Fixed it.

    The  concatete function needs have text to work with

    Set(VarNextCustomerID, Concatenate(Text(VarNextID),"TR",TEXT(VarCurrentYear))); 

     

    and problem was fixed

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard