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

Notifications

Announcements

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:
I have the same question (0)
  • eka24 Profile Picture
    20,923 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
    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard