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.

New Icon in SharePoint

I have a client who wanted to control how long an item will be shown as new in SharePoint List. Later scrutinizing I have found that it's an configuration issue. There's nothing development required. I have got the link helpful http://my.advisor.com/doc/17728
The !New icon displays next to a new list item in a list or document library for a defined amount of time based on the "days-to-show-new-icon" virtual server property. You can modify this property using the operation setproperty in the stsadm.exe command-line tool. For example, this command sets all occurrences of new list and document library items in the http://wss1 site collection to display the "!new" icon for two days:

stsadm.exe -o setproperty  -pn days-to-show-new-icon -pv 2 -url http://wss1

To remove the !New icon all together, simply set the –pv value to 0.