0

I am creating a site column of type "CALCULATED" through visual studio. Here is my scehma . when i try to deploy it gives the below exception

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">  
  <Field
       ID="{b63b3de8-174c-40b9-94ab-d6be03498141}"
       Name="Download File"
       DisplayName="Download File"
       Type="Calculated"
       Required="FALSE"
       Group="Custom Site Columns"
       ResultType="Number">
    <Formula>
 [='<A href="#"><span class="fa-stack fa-lg"><i class="fa fa-square-o fa-stack-2x"></i><i class="fa fa-download fa-stack-1x" data-toggle="tooltip" data-placement="bottom" title="Download this File"></i></span></A>']
    </Formula>
  </Field>
</Elements>

ExCEPTION

Error occurred in deployment step 'Add Solution': Feature definition with Id <FeatureID> failed validation, file 'xxx\Elements.xml', line xx, character xx: The element 'http://schemas.microsoft.com/sharepoint/:Formula' cannot contain child element 'http://schemas.microsoft.com/sharepoint/:input' because the parent element's content model is text only.

How to tackle this error?

1

In SharePoint Formulas only double-quotes " are string delimiters

'<A href="#"><span class="fa-stack fa-lg"><i class="fa fa-square-o fa-stack-2x"></i><i class="fa fa-download fa-stack-1x" data-toggle="tooltip" data-placement="bottom" title="Download this File"></i></span></A>'

Must become:

"<A href='#'><span class='fa-stack fa-lg'><i class='fa fa-square-o fa-stack-2x'></i><i class='fa fa-download fa-stack-1x' data-toggle='tooltip' data-placement='bottom' title='Download this File'></i></span></A>"

If you need a double-quote inside a SharePoint Formula you have to use the escape notation "" (two double quotes) Usually only needed when you add JavaScript events to your HTML code because it requires 2 quoting styles inside an allready quoted SharePoint string.

Also note the browser will add double quotes around Words, so

"<A href=#><span class='fa-stack fa-lg'><i class='fa fa-square-o fa-stack-2x'></i><i class='fa fa-download fa-stack-1x' data-toggle=tooltip data-placement=bottom title='Download this File'></i></span></A>"

is valid also

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.