On a recent project, I was migrating a customer from the Contracts object to a Custom Object (Contracts are not supported in Customer Portal for some odd reason). The Contract Number was being imported to the Name field on the new Custom Object. To do so, I had to make the Name field a Text field so that we could maintain the value. We also wanted to keep the formatting of 00000123 for contract #123.
After import, I converted the Name field to an Auto Number and set its mask to be {00000000} and its starting number to be the next one in the sequence. When you change from a Text to an Auto Number field on the Name field of a Custom Object, the old data is left alone. Had I imported, “123″ into the Name field, Salesforce would not apply the mask. Thus, I had to import “00000123″ on the migrated records.
The issue my client discovered is that you can’t search for “123″ in the Sidebar Search to find the Custom Object record that was imported. It will work for records generated after the field was changed to an Auto Number, but not the converted data. To find the legacy data, we’d have to tell the users to search for the full value of “00000123″. Not good.
The resolution was actually pretty simple. I added a new text field to the object and have a Workflow Rule that copies the Contract Number to it. On Custom Objects, all text fields are indexed. Voila! It was searchable.