I am trying to add some fields to list using the client object model. Everything is working except the Calculated field.

Every time SharePoint gives the error: An error occurred while parsing EntityName

"<Field Type='Calculated' DisplayName='Periode' LCID='1043' Name='Periode' ResultType='Text' ReadOnly='TRUE'><Formula>=RECHTS(\"00\"&MAAND([Rapportage periode]);2)&\"-\"&TEKST([Rapportage periode];\"YYYY\")&\"(\"&TEKST([Rapportage periode];\"MMMM\")&\")\"</Formula><FieldRefs><FieldRef Name='Rapportage periode' /></FieldRefs></Field>"
, true, AddFieldOptions.AddFieldToDefaultView);

My question is, What on earth am i doing wrong? I have tested the formula, and it works fine.

Further on, adding the column with the formula:

=[Rapportage periode] 

works, adding the formula:

=RECHTS("00"&MAAND([Rapportage periode]);2)&"-"&TEKST([Rapportage periode];"YYYY")&" ("&TEKST([Rapportage periode];"MMMM")&")"

in the interface works.


Ok, after lots of trial and error i got it.

Turns out that

  • A, no matter the locale of the site collection, the Client object model must enter in the english syntax.

  • B, " and & throw syntax errors unless written as & quot; and & amp; so the correct code is:

    <Field Type='Calculated' DisplayName='Periode' LCID='1043' ResultType='Text'><Formula>=RIGHT(&quot;00&quot;&amp;MONTH([Rapportage periode]),2)&amp;&quot;-&quot;&amp;TEXT([Rapportage periode],&quot;YYYY&quot;)&amp;&quot; (&quot;&amp;TEXT([Rapportage periode],&quot;MMMM&quot;)&amp;&quot;)&quot;</Formula><FieldRefs><FieldRef Name='Rapportage periode'/></FieldRefs></Field>

Can you create that throught the UI? I'm not sure about the formula.. but I guess you are missing the space conversion x0020

So it encodes like this: Rapportage_x0020_periode

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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