Total Pageviews

Search This Blog

Thursday, December 8, 2011

Tip str2CapitalWord function to convert string into TitleCase

We have some custom export routines written in our solution which ftp's .csv file from AX. Now, the target system needed one of the column names in TitleCase.

In my previous experience, I have used strUpr and strLwr functions in AX, but never had a requirement to convert something into TitleCase, Initially, for a quick workaround, I used Proper function in Excel to convert the column into TitleCase. But, the right way to fix was in the source program. so as soon as I got some time did bit of digging in AX standard functions and found out we have 2 functions:

1. str2Capital 

    This function just converts the first letter of the word as UpperCase so didn't match my requirements e.g.
     Input String : "new south wales"

     Output String: print str2Capital("new south wales") returns New south wales

2. str2CapitalWord
     This function was exactly what I was looking for. It converts the first letter of each word in the sentence to     
      Input String: "new south wales"
      Output String: "New South Wales"

No comments: