Showing posts with label currency. Show all posts
Showing posts with label currency. Show all posts

Thursday, April 7, 2011

Odd Currency Symbols returned from FetchXML

While working with CRM2011 FetchXML, I came across a nasty issue when retrieving a currency field. I have done this successfully many times before, but for some reason this time I was getting multiple currency symbols in my raw XML result, ie:

$‎5,000

instead of the desired:

$5,000

Adding transactioncurrencyid to the fetch did not help, and replacing "$‎" with "$" directly also did not work. However, after toying about with the string in unicode for a bit, I came up with:

value = Regex.Replace(value, "\u200e", "");

This properly removed the funky symbols, leaving me with "$5,000". Likely something under the hood is causing an issue elsewhere, but this is a great workaround if you just need to get a properly formatted currency field without hacking deeper into the CRM platform.