Search

  • Home
  • Screencasts
  • Speaking
  • Downloads
  • Consulting Services
Browsing: / Home / 2010 / February / 06 / Provisioning validation formula to SharePoint 2010 list field
Print Email Shortlink

Provisioning validation formula to SharePoint 2010 list field

By Yaroslav Pentsarskyy on February 6, 2010 in sharepoint, sharepoint 2010
Tweet

SharePoint 2010 has a really cool feature allowing you to create validation formula on the list field and display a message to a user if validation fails. Something I have been using custom Rendering Templates and Event Handlers in MOSS.

Here we`ll take a look at how e can provision such special fields using VisualStudio 2010 features.

First, here is how our formula was defined in a field settings:

validation formula

Here is the result when the number new item is created:

validation message

In your Visual Studio 2010 you can define the field right in the schema.xml of the list definition where your field will appear.

Here is how something like this would look like:

<Field Type=”Number” DisplayName=”TestNumber” ID=”{e47ae7ad-fb63-4ead-a50c-4143f86e727f}” StaticName=”TestNumber” Name=”TestNumber”>
<Validation Message=”Test Number must be greater than 0″ Script=”function(x){return SP.Exp.Calc.valid(SP.Exp.Node.f(‘GT’,[SP.Exp.Node.a(0),SP.Exp.Node.v(0)]),x)}”>
=TestNumber&gt;0
</Validation>
</Field>

The highlighted part defines the formula just like in the UI and pretty much follows calculated field syntax, so you can go pretty complex here.

Good luck!

Share this on: Mixx Delicious Digg Facebook Twitter
sharepoint 2010sharepoint field validationspfield validation formula
  • Related Stories
  • Most Popular
  • How to: avoid duplicate load of jQuery, or else!
  • How to: automatically package your SharePoint 2013 branding solutions with design manager
  • How To: improve SharePoint/Office 365 site SEO with page keywords and meta description
  • SharePoint 2013 training for developers
  • How to: setting property bag properties on a web in SharePoint online
  • Enabling geolocation field in your SharePoint 2013 list using an app
  • Enabling geolocation field in your SharePoint 2013 list using an app
  • SharePoint Branding: add a handy function to allow users show/hide quick launch bar
  • Add SharePoint 2010 quick launch toggle on/off feature
  • Modify out of the box and custom SharePoint 2010 workflow forms
  • Creating WCF service in SharePoint 2010
  • SharePoint 2010 Branding: defining new Content Query roll up rendering template
← Previous Next →

Just Released! My SharePoint 2013 Book

My SharePoint books & DVD

Copyright © 2013 sharemuch.com.

Powered by WordPress and News.