Somehow one of my users managed to get a vertical tab stuck in a text field (ascii 0x0B) for a CRM Entity. How they did this is quite beyond me. The problem though is that once it made it in it basically made that entity useless. Trying to pull it up causes CRM to puke. Actually, not CRM itself, but the XmlSerializer underneath throws an exception about an invalid character in the XML document.
Tracking this down was a real PITA. Luckily I new the entity was created on a specific day so I was able to narrow things down until I knew precisely which entity had the data. Then I was able to go to the DB and look for it. Now comes the problem:
I have administrator access inside of CRM. But I’m a fairly restricted user on the DB side. If I had Admin access to the DB this wouldn’t even rate a mention. However, I’m not certain of the table name so I can’t just write the query and send it over to the SQL admin to do (He is in another state). Plus he is in an all day meeting. What to do?
The solution isn’t too bad really: write a simple console app that retrieves the entity without any of its properties. Add the property you need to fix (I copy and pasted the value from SQL and replaced the offending character with a space) and then use an UpdateRequest to finish the job.
My bigger concern going forward is how to prevent this in the first place. Do I need to write a plug-in that scans every single entity as it goes in? Or add script to every form to check fields? Either way seems like a ton of work.
Or maybe this will be a one every few months deal, in which case just a quick breakfix job might be good enough.