none
Calculated Field Formula in CAML RRS feed

  • Question

  • So I have a formula in a calculated field in CAML in an XML file with my content type.  It works, but it has different effects if I deploy it to a URL with a host name vs. a URL without a host name.  Very odd, right?

    So here's the field definition:

     

    <Field ...>
    	<Formula>=IF([Completed Effort]&gt;[Estimated Effort],1,[Completed Effort]/[Estimated Effort])</Formula>
    	<FieldRefs>
    		<FieldRef Name="Estimated_Effort"/>
    		<FieldRef Name="Completed_Effort"/>
    	</FieldRefs>
    </Field>
    

     

    If I deploy this to a site collection set up at a URL like so: http://machine:port/sites/somesite, it works fine when I create a list programmatically from a list definition.  If I deploy this to a site collection with a URL like so (hostname): http://moss.domain.com/, it doesn't break, but it replaces the field names in the formula with "#NAME?" and thus the calculated field is incorrect.

    Now, if I change the formula so that it uses the static name like so:

     

    <Formula>=IF([Completed_Effort]&gt;[Estimated_Effort],1,[Completed_Effort]/[Estimated_Effort])</Formula>
    

     

    It works fine in the site with the hostname but I get the following error when I try to programmatically create a list using a list definition:

    "The formula refers to a column that does not exist"

    So what gives?  The two site collections are on the same server and obviously with the same version of SharePoint.  How can one site treat the formula CAML differently from the other? 


    http://www.charliedigital.com
    Thursday, April 21, 2011 12:28 AM

All replies

  • I tested again this morning with a different site collection.  This time, using a combination of hostname and /sites/ and found that it behaves as it does in the managed path scenario above.

    So it seems that there's something about using /sites/ (managed paths) when creating a site collection which causes the behavior of the calculated field <Formula /> element to behave differently.

    I also came across a the <FormulaDisplayNames /> field last night as well, yet I don't think it has any effect on the behavior of the content type at all.

    Any insight would be appreciated!


    http://www.charliedigital.com
    Thursday, April 21, 2011 3:12 PM