I'm trying to generate a calculated field (MOSS 2007) from the schemaXml of another field, that looks as shown below.
The calc field refers to another filed called "Base Num". Due to the space in the name, the internal and display name are different.
<Field Type='Calculated' DisplayName='CalcNum' Format='DateOnly' LCID='1033' ResultType='Text' ReadOnly='TRUE' ID='{cd60edd0-4750-4ac5-b7fa-50691baf3226}' SourceID='{dfdfbdc6-25b7-45d4-8b0d-71906d519225}' StaticName='ACalcNum' Name='ACalcNum' ColName='sql_variant3' RowOrdinal='0'>
When I call myList.Fields.AddFieldAsXml with the above string I get exception "The formula refers to a column that does not exist",
although Base Num does exist.
I've seen the same exception with a similar situation: after renaming a referenced field, its internal and display name are different, and adding a calculated field that refers to it will fail with the same error.
Please note that I don't build the the CAML string I'm using for AddFieldAsXml; it is simply copied from the schemaXml of another calc field. I would prefer not to change this string, becaue it might contain a complex formula and by processing it I might ruin it.
Any ideas?
Thanks in advance
Sruli Ganor