简体   繁体   中英

Only allow one entry per User in a List - ListReceiver “Feature” for a List?

I wonder if there is a way to create a Custom List in Sharepoint, but specify that each user may only create one item in the list.

I am thinking of two approaches:

  • Develop a ListReceiver that checks if the user already created an item. Problem: I did not see a way to enable a Feature on a specific list (the idea is that non-developers can just create a custom list and "switch on" the Feature if they want
  • Create a Custom List Type, so when people click the "Create" Button, they see "Custom Unique List" under "Custom Lists" as an additional type.

Before I do the second option, does anyone know if the first option is possible? Or even if it can already be done without custom development (and without a custom workflow in SPDesigner)

Without custom code you are out of luck. You can easily add a receiver to a single list using code, just add the receiver to the SPListItem.EventReceivers collection as such:

list.EventReceivers.Add(SPEventReceiverType.ItemAdded, "YOUR STRONG NAME", "YOUR CLASS NAME");

There is no way directly through a feature elements file, however.

If you want an option to enable or disable the feature on a particular list you can also add a CustomAction and bind it to that specific list template for instance so that an extra Action menu item allows Enable or Disable Unique Posts.

.b

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM