0

I have following Columdefs

   <Field ID="{64cd368d-2f95-4bfc-a1f9-8d4324ecb007}" Type="DateTime" ShowInDisplayForm="TRUE" Name="StartDate" DisplayName="$Resources:core,Start_Date;" Format="DateOnly" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="StartDate">
    <Default>[today]</Default>
  </Field>
  <Field Type="DateTime" ID="{cd21b4c2-6841-4f9e-a23a-738a65f99889}" Name="DueDate" DisplayName="$Resources:core,Due_Date;" Format="DateOnly" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="DueDate"></Field>
  <Field Type="Calculated" DisplayName="Dauer" ResultType="Number" ReadOnly="TRUE" ID="{f268d15f-a082-4bf4-833b-ca1691117cb4}" StaticName="Dauer" Name="Dauer" ColName="sql_variant1" RowOrdinal="0">
    <Formula>=DATEDIF([StartDate],[DueDate],"d")</Formula>
    <FieldRefs>
      <FieldRef Name="DueDate" />
      <FieldRef Name="StartDate" />
    </FieldRefs>
  </Field>

With this definition i get an ArgumentOutOfRangeException Here ist the full stack trace

System.ArgumentOutOfRangeException: Das angegebene Argument liegt außerhalb des gültigen Wertebereichs. bei Microsoft.SharePoint.SPFieldCalculated.GetFieldValueAsTextOrHtml(Object value, Boolean asHtml) bei Microsoft.SharePoint.JSGrid.GridSerializer.LocalizeField(DataRow dr, GridField field, Object dataValue) bei Microsoft.SharePoint.JSGrid.GridSerializer.CreateLocalizedData(IEnumerable`1 unlocalizedSlicedRows) bei Microsoft.SharePoint.JSGrid.GridSerializer.BuildOutput() bei Microsoft.SharePoint.JSGrid.GridSerializer.ToJson(Serializer s) bei Microsoft.SharePoint.JsonUtilities.Serializer.SerializeToJson(Object o) bei Microsoft.SharePoint.WebControls.JSGrid.get_StartupScript() bei Microsoft.SharePoint.WebControls.JSGrid.Render(HtmlTextWriter writer) bei System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) bei System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) bei System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) bei Microsoft.SharePoint.WebPartPages.ListViewWebPart.RenderWebPart(HtmlTextWriter output) bei Microsoft.SharePoint.WebPartPages.WebPart.Render(HtmlTextWriter writer) bei Microsoft.SharePoint.WebPartPages.WebPartMobileAdapter.Render(HtmlTextWriter writer) bei System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) bei Microsoft.SharePoint.WebPartPages.SPChrome.RenderPartContents(HtmlTextWriter output, WebPart part)

When I remove the formular, it works very well. What can be the problem in there?

2 Answers 2

1

You will have to encode your formula, in this example replace " with &quot;

<Formula>=DATEDIF([StartDate],[DueDate],&quot;d&quot;)</Formula>
2
  • thx for the suggestion, but the result is the same. :(
    – Sascha
    Feb 19, 2014 at 10:16
  • Strange, Have you tried setting it up in the GUI and then export the list as template. (Download and rename the file to name.cab). There you will see how SharePoint has constructed the XML for the field :) Feb 19, 2014 at 10:19
0

I think formulas use the display name rather than the internal name.

As I am a non-developer I am unsure looking at your script what the display names are but they seem to include underscores?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.