I am using this in an xml transformation and just recently noticed it doesn't work with high numbers that start with like 877.
{% FormatString("{0: (###) ###-####}",Primary.ToInt()) #%}
Any thoughts on what I can do to get those to work?
I've also noticed that if I type in the number manually, it doesn't work when the number is too big
{% FormatString("{0: (###) ###-####}",8779999999); #%}
returns this "(19) 006-5407"
This is what I ended up doing.
x = "(" + Phone.SubString(0, 3) + ") " + Phone.SubString(3, 3) + "-" + Phone.SubString(6, 4); return x;
Hi Lawrence,
Looking at your code, converting phone number to integer looks really strange. Typical phone number is obviously bigger than int can accommodate, therefore you get this weird behaviour.
Your second solution looks a bit better. However instead of formatting this on the backend I'd recommend doing it via JS when you display these numbers, please refer to this article for example.
Please, sign in to be able to submit a new answer.