SPList.ValidationFormula Property
Gets or sets a formula that is evaluated each time that a list item is added or updated.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax
'Declaration
<ClientCallableConstraintAttribute(Type := ClientCallableConstraintType.NotNull, Sequence := )> _
<ClientCallableConstraintAttribute(Type := ClientCallableConstraintType.MaxLength, Value := , Sequence := )> _
<ClientCallablePropertyAttribute(ExcludeFromDefaultRetrieve := True)> _
Public Property ValidationFormula As String
Get
Set
'Usage
Dim instance As SPList
Dim value As String
value = instance.ValidationFormula
instance.ValidationFormula = value
[ClientCallableConstraintAttribute(Type = ClientCallableConstraintType.NotNull, Sequence = )]
[ClientCallableConstraintAttribute(Type = ClientCallableConstraintType.MaxLength, Value = , Sequence = )]
[ClientCallablePropertyAttribute(ExcludeFromDefaultRetrieve = true)]
public string ValidationFormula { get; set; }
Property Value
Type: System.String
The formula that will be used to evaluate data in the item. The rules for constructing a formula are similar to those for creating formulas for calculated fields. For more information, see Calculated Field Formulas.
Exceptions
Exception | Condition |
---|---|
ArgumentException | The string is too long. The maximum length of a validation formula string is 1024. |
Remarks
Each time that a list item is added or updated, the validation formula is evaluated. If the formula evaluates to false, or if a calculation error occurs, the update is not permitted and the message in the ValidationMessage property is displayed.
Keep in mind that each field in a list item has a ValidationFormula property of its own. The difference is that the validation formula for a field can refer only to that field, whereas the validation formula for a list item can refer to several or even all fields in the item.
Note
Formula validation is independent of the type of validation controlled by the EnforceDataValidation property.