views:

16

answers:

1

I have custom list in sharepoint and I am doing validation through sharepoint designer using Jquery. My requirement is I want to access list items from sharepoint in the client side before I can enter new data.

Is there anyway I can access custom list items before I can push new list items in to the custom list.

If I can access then I will make sure no duplicates are being entered into the list.

Could anyone help this.. Or could any one suggest any other approach to fulfill my requirement.

Hari

+1  A: 

There is a jQuery plugin for accessing SharePoint list data. You could use this to retrieve items and compare them. This will not be very fast as the number of list items grows.

Alternatively you can write an Event Handler and attach it to the list. With this, you can attach to a list's OnAdding call. You can examine the list for duplicates and set the cancel flag on the operation if the item would cause a duplicate. This would take longer to build and customize your list but might be the better approach.

Lists expose OnAdding OnAdded OnUpdating OnUpdated OnDeleting OnDeleted. When they are fired is obvious. The 'ing' functions are fired as the operation is in progress and you can stop the event from succeeding. The 'ed' functions are fired after the completion of the activity.

Erik Noren
I never wrote an event handler. I am not sure how to do that..May be if you have some time could you advice me were to start..
Hari Gillala
The link on Event Handler is a pretty good conceptual resource and shows how to do it fast and dirty. The alternative involves creating a custom list template and event handler, your own feature file and packaging it up into a WSP package, adding it to SharePoint and deploying it. The actual code for handling the event is the same. The approach to packaging and deploying is completely up to you given your environment, rights, etc.
Erik Noren

related questions