Tuesday, May 27, 2008

Delete Parent List of Lookup Column

I have a parent child relationship between Product and ProductOrder list. Now if an user wants to delete an item from Product list whereas an order is made for the product (i.e., an ProductOrder list item refer to the product),  I need to prevent the user from deleting the product. The way I can ensure:

  1. If we use SharePoint built-in List viewer with SharePoint lists' context menu then I can write a feature which will use EventReceiver to listen the Product lists' delete event. If there's any item in  ProductOrder list which refers to the product attempted to delete, then the delete operation will be stopped from code.
  2. If we use SharePoint built-in List viewer but hide the SharePoint provided context menu and use custom menu, then we can control the delete operation with a hidden user control. The delete operation will be implemented in in the code behind of the user control. As our own code is going to delete the item using SharePoint object model we can easily handle the delete operation the way we want.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.