Enforce Unique Values for external data type column - I know that it is not possible out of the box. What are the soultions for validating external data type columns for duplicates? workflows? others?
Enforce Unique Values for external data type column in sharepoint
1.4k Views Asked by marcinn At
2
There are 2 best solutions below
0
On
Though it doesn't seem to mention it in the MS Documentation you can Enforce uniqueness onto an 'External Data' type column using PowerShell. I've just tried the example below and it works on an SP2013 Farm.
Example from Office DEV Center
SPSite site = new SPSite("http://localhost");
SPWeb web = site.OpenWeb();
SPList custList = web.Lists["Customers"];
SPField custPhone = custList.Fields["Phone Number"];
custPhone.Indexed = true;
custPhone.EnforceUniqueValues = true;
/// You must call the Update() method
/// when you change the EnforceUniqueValues property
custPhone.Update();
Well, external lists can't have workflows or event receivers where you could validate data, so doing this in SharePoint would actually be very complicated. My opinion is that you should validate your data before importing it into SP. If your datasource is a DB then add a constraint, if it's a web service then the external system should enforce uniqueness, if it's a custom external content type you can enforce it through code.