Today I tried to copy a calculated field from one list to another (in another site collection). For other field types I used the SchemaXml member and the AddFieldAsXml method of the SPFieldCollection class. Testing on my development machine was fine, everything worked as expected, but in the real world, the calculated field was not copied. What was wrong?

While testing, my internal and display names of the referenced fields were identical. In the real world scenario, the display name was modified, so the internal and the display name were different. After some investigation, I think I got the answer. The SchemaXml contains a Formula-node. When setting the SchemaXml member to a new value, the Formula-node should contain the display names of the referenced fields. But when you read the SchemaXml member, you will get the internal names of the referenced fields in the Formula-node. Strange, isn’t it?