3

I wanna apply item level permissions for 7 document libraries with different kind of permission levels for different groups.

So, in order to achieve this, should i write 7 different sharepoint projects/solutions or can i combine all these item level permissions [ itemadded event receiver or itemupdated ] in one single VS 2013 sharepoint solution?

2

I recommend you have a single solution for the event receiver that simply references the library name or URL to decide it's logic for assigning permissions.

  • how to create in a single solution? because if we create 7 sp projects within a single solution, it wil become 7 different WSPs. should i add a 7 different event receiver template files within a single solution? in case after going live , in prod, if there is ant business logic change, my cide has to be altered for the entire solution so this is an disadvantage. – userAZLogicApps Mar 17 '17 at 17:10
  • 1
    Just have one solution with one event receiver project template. That event receiver would then have defined logic based on the library it's being triggered from. As for the business logic, it would be best to break it down to values you could capture in a secured list in SharePoint which would allow you to later modify the event receiver's action without the need for a recompile/redeployment. It would be best to use the psst tense event receiver i.e. ItemUodated instead of ItemUpdating since the former is asynchronous while the latter is synchronous and would degrade your user experience. – Cornelius J. van Dyk Mar 17 '17 at 17:27
  • I have used one generic splist for naming all the doc libs with the permissions defined. On itemupdated am calling this list . – userAZLogicApps Mar 17 '17 at 17:34
1

No need to create a specific solution for every document library, Just create one SharePoint solution with an event receiver for a Document Library as shown below:

enter image description here

Note: In Elements.xml don't change ListTemplateId="101" theat denote to document library

In each event, you have selected. you can check if the doc title equal a specific doc library title, then write your code based on each library as the following:

public override void ItemUpdating(SPItemEventProperties properties)
        {
            if (properties.ListTitle == "doc lib1")
            {
               // do something for doclib1
            } else if (properties.ListTitle == "doc lib2")
            {
               // do something for doclib2
            }
        } 

Note: If you need to apply an event receiver that will do the same action for all 7 document libraries. in this case, you can create a one content type for all libs and attach the event receiver to this content type for more details check Programmatically Adding an Event Receiver to a Content Type

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.