Check if sharepoint item exists in another list.

Highlighted
New Contributor

Please help. I have 2 SharePoint Online lists. List A and B, I have a autocomplete field in B that retrieves data from A. I want to block users from saving in B if item in A does not exists. Thank you.

2 Replies
Highlighted

Hi @Thamsanqa Langa you could just make that lookup field mandatory, as your user will then be forced to select a valid option. The frustrating thing with Lookup Columns is that if you don't make them mandatory at the point of creation, you can't change it afterwards through the SharePoint UI. If you don't have any data in there at the moment, delete the column and recreate it. Otherwise let us know and I'm sure we can supply some PowerShell to do the same.

Highlighted

Thank you very much for the response. Initially I had a lookup field which worked very well and served the purpose but when the master list exceeded 5000 items the lookup control broke because it had reached its limit. So I had to change the control into a autocomplete single line text using the $().SPServices.SPAutocomplete function found here https://sympmarc.github.io/SPServices/value-added/SPAutocomplete.html , my single line text does lookup to the master list which is great but it also allows or save entries that don't exist in the master list. I'm looking for a way to prevent users from entering entries in the list that don't exist in the master list.