How to get the last 4 digit from a string in AJO | Community
Skip to main content
Level 2
August 23, 2024
Solved

How to get the last 4 digit from a string in AJO

  • August 23, 2024
  • 2 replies
  • 649 views

I have to get the last 4 digit from the account number. How to achieve that in the AJO

Best answer by Mohan_Dugganab

You can validate it on the following lines 

{%= substr(toString(<ReplaceWithAccountNumber>), length(toString(<ReplaceWithAccountNumber>))-4, length(toString(<ReplaceWithAccountNumber>))) %}

2 replies

Mohan_Dugganab
Adobe Employee
Mohan_DugganabAdobe EmployeeAccepted solution
Adobe Employee
August 23, 2024

You can validate it on the following lines 

{%= substr(toString(<ReplaceWithAccountNumber>), length(toString(<ReplaceWithAccountNumber>))-4, length(toString(<ReplaceWithAccountNumber>))) %}
Adobe Employee
August 28, 2024

Hello @niteshsingh ,

 

If your usecase is to display the last 4 digits of account number by masking it. we have below mask function,

 

{%= mask("123443216789",0,4) %}

  - this function will keep last 4 digits as it is and mask the remaining as X.

 

Output - XXXXXXXX6789

 

If your usecase is to get last 4 digits for other calculation you can refer the code suggested by @mohan_dugganab