Blog Archive

SharePoint-courses
José Quinto Zamora

MoveTo and List Data Validation in SharePoint 2010 (ValidationFormula)

2011-05-16 11:51:00 by José Quinto Zamora

If you have in your SharePoint 2010 list (or library) a Column Validation:

image

 

And, also you need Event Receiver that moves a document between folders (in the same library). If you use Microsoft.SharePoint.SPFile.MoveTo to move or rename a Document. Then you maybe will have a problem like this:

This operation is not supported because the destination document library contains a

list data validation formula or has the EnforceDataValidation property set., Stacktrace:   

at Microsoft.SharePoint.SPFile.MoveCopyInternal(String strNewUrl, Int32 grf, Boolean requireWebFilePermission)

at Microsoft.SharePoint.SPFile.MoveTo(String newUrl, SPMoveOperations flags)

 

You can solve this problem modifying Validation Formula:

'Remove List Data Validation
Dim tempFormula As String = properties.List.ValidationFormula
properties.List.ValidationFormula = ""
properties.List.Update()

'Move Document
item.File.MoveTo(completeName)
item.File.Update()

'Re-asign ValidationFormula
properties.List.ValidationFormula = tempFormula
properties.List.Update()

 

Regards!

JQ

Comments

No Comments
Leave a Comment
(*) Title:
(*) Name:
Your URL:
(*) Comments:
Follow us on: