locked
Add Item, Delete Item, Edit Item not allowed for Custom list. RRS feed

  • Question

  • Hi,

    I created Custom list using visual studio list definition.

    I don't want to allow to add,edit and delete items.

    How can I diable these features?

    Thanks in advance!


    Best Regards, wendy

    Monday, July 23, 2012 8:52 AM

Answers

  • Hi,

    Thanks for reply.

    Actually, I want to use Event Receiver for the users not allow to add, edit and delete items.

    I created Event Receiver for this list. Delete is ok but how to write for add and edit items.

    public override void ItemDeleting(SPItemEventProperties properties)
           {
               properties.Status = SPEventReceiverStatus.CancelWithError;
               properties.ErrorMessage = "Item is not allowed to delete.";
           }


    Best Regards, wendy

    • Proposed as answer by Aviw_ Monday, August 6, 2012 5:59 AM
    • Marked as answer by wendy.sh Monday, August 6, 2012 7:00 AM
    Wednesday, July 25, 2012 9:10 AM
  • Hi Wendy,

    Do the same process for add and edit operation :

     public override void ItemAdding(SPItemEventProperties properties)
           {
               properties.Status = SPEventReceiverStatus.CancelWithError;
               properties.ErrorMessage = "Item is not allowed to Add.";
               base.ItemAdding(properties);
           }
    
           /// <summary>
           /// An item is being updated.
           /// </summary>
           public override void ItemUpdating(SPItemEventProperties properties)
           {
               properties.Status = SPEventReceiverStatus.CancelWithError;
               properties.ErrorMessage = "Item is not allowed to Edit.";
               base.ItemUpdating(properties);
           }


    Mukesh Ajmera

    • Proposed as answer by Bjoern H Rapp Wednesday, July 25, 2012 9:32 AM
    • Marked as answer by wendy.sh Monday, August 6, 2012 7:01 AM
    Wednesday, July 25, 2012 9:23 AM
  • I do same process for edit and add but I got this error message.

    Change status:

    properties.Status = SPEventReceiverStatus.CancelNoError;


    My contributions: SharePoint 2010 Solution Installer

    • Marked as answer by Qiao Wei Monday, August 6, 2012 2:11 AM
    Sunday, August 5, 2012 9:50 AM

All replies

  • using SharePoint permissions you could just set only the Permissions Read for a specified group for this list.

    http://gilleslauwers.wordpress.com

    • Proposed as answer by Bjoern H Rapp Wednesday, July 25, 2012 9:42 AM
    Monday, July 23, 2012 8:59 AM
  • Hello wendy.sh,

    As Gilles suggested you can give the list read permission to the specific group you can restrict the user to Add/Update/Delete the list item.

    So for that first you need to stop inherit the list permission and give specific user group to only read permission.

    you can follow below links to grant the permission to the list.

    http://sharepoint.microsoft.com/Blogs/GetThePoint/Lists/Posts/Post.aspx?ID=533


    Hiren Patel | Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.


    Monday, July 23, 2012 9:15 AM
  • Hi,

    Thanks for reply.

    Actually, I want to use Event Receiver for the users not allow to add, edit and delete items.

    I created Event Receiver for this list. Delete is ok but how to write for add and edit items.

    public override void ItemDeleting(SPItemEventProperties properties)
           {
               properties.Status = SPEventReceiverStatus.CancelWithError;
               properties.ErrorMessage = "Item is not allowed to delete.";
           }


    Best Regards, wendy

    • Proposed as answer by Aviw_ Monday, August 6, 2012 5:59 AM
    • Marked as answer by wendy.sh Monday, August 6, 2012 7:00 AM
    Wednesday, July 25, 2012 9:10 AM
  • Hi Wendy,

    Do the same process for add and edit operation :

     public override void ItemAdding(SPItemEventProperties properties)
           {
               properties.Status = SPEventReceiverStatus.CancelWithError;
               properties.ErrorMessage = "Item is not allowed to Add.";
               base.ItemAdding(properties);
           }
    
           /// <summary>
           /// An item is being updated.
           /// </summary>
           public override void ItemUpdating(SPItemEventProperties properties)
           {
               properties.Status = SPEventReceiverStatus.CancelWithError;
               properties.ErrorMessage = "Item is not allowed to Edit.";
               base.ItemUpdating(properties);
           }


    Mukesh Ajmera

    • Proposed as answer by Bjoern H Rapp Wednesday, July 25, 2012 9:32 AM
    • Marked as answer by wendy.sh Monday, August 6, 2012 7:01 AM
    Wednesday, July 25, 2012 9:23 AM
  • Hi Mukesh,

    Thank you for your reply.

    I do same process for edit and add but I got this error message. How can I do to get error message like delete operation?



    Best Regards, wendy

    Thursday, July 26, 2012 9:53 AM
  • Hi wendy,

    can you please specify the error message


    Hiren Patel | Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.

    Saturday, August 4, 2012 2:35 PM
  • I do same process for edit and add but I got this error message.

    Change status:

    properties.Status = SPEventReceiverStatus.CancelNoError;


    My contributions: SharePoint 2010 Solution Installer

    • Marked as answer by Qiao Wei Monday, August 6, 2012 2:11 AM
    Sunday, August 5, 2012 9:50 AM