As a work around I created the field using the object model and then
setting it's schema to reference the field in the infopath form.
The key is to not call the Update() on the field, if you do it
doesn't save the new value for some reason. It doesn't make sense.
See below.
<Field ReadOnly=""TRUE"" DisplayName=""ActionStatus""
Name=""ActionStatus"" Node=""/MonthlySafeActionPlan/Action/@Status""
Type=""Text"" ColName=""nvarchar10"" />
After this I would create the calculated field using the object
model and then set it's schema to something like this:
<Field Type=""Calculated"" DisplayName=""Status""
Format=""DateOnly"" LCID=""1033"" ResultType=""Text""
ReadOnly=""TRUE"" Name=""Status""
ColName=""sql_variant1""><Formula>=IF
(ActionStatus=""O"",""Open"",""Closed"")
</Formula><FieldRefs><FieldRef
Name=""ActionStatus"" /></FieldRefs></Field>
Do not call the update() on the field after you do this.
When you publish an infopath form to a form library you have the
option to create fields in the form library that will display data
from the infopath form. If you do this the name of your field will
be an ugly system generated name. Then I wasn't able to use this
system generated name to set the formula. It's much easier to just
create the fields using the object model and then pointing it to the
correct field in the infopath form.