Forum Discussion

Deleted's avatar
Deleted
Oct 18, 2016

Default column value - Event Receiver

I have a library with a Document Set as its Content Type. This DS will have 5 folders in each item. I would really like to set the default column value for each item within the folder when an item is added. The Default column value functionality doesnt work on Document sets so an event receiver is the best option because I have had minimal luck with consistency for Workflows. Can you tell me if the consistency of the Event Receivers in a production environment are trustworthy to fire EVERY TIME?

11 Replies

  • Don DeCarlo's avatar
    Don DeCarlo
    Brass Contributor

    I came accross this "how to" article recently and thought it was interesting.

     

    http://social.technet.microsoft.com/wiki/contents/articles/34873.sharepoint-2013-how-to-enable-remote-event-receivers-with-existing-list-libraries.aspx

     

    I haven't not had a chance to run through the steps on my own but thought I would pass it on to you.

     

    Thanks

    Don

     

    • Levi Johnson's avatar
      Levi Johnson
      Brass Contributor

      For what it's worth, it's much easier to set the Event Recievers directly on the list through CSOM. Once your remote event receiver is deployed to azure, you can use the following code to wire it up:

       

      EventReceiverDefinitionCreationInformation eventReceiver = new EventReceiverDefinitionCreationInformation();

      eventReceiver.ReceiverName = recieverName;
      eventReceiver.ReceiverUrl = AZUREURL + "/Services/" + recieverName + ".svc";
      eventReceiver.SequenceNumber = 1000;

      eventReceiver.EventType = EventReceiverType.ItemAdded;
      targetList.EventReceivers.Add(eventReceiver);
      clientContext.ExecuteQuery();

       

      and viola! You have a working Remote Event Receiver. 

  • Hi Deleted,

     

    Which version of SharePoint are you using? As you are talking about event receivers I'm assuming that you are using SharePoint on-premises.

     

    I would be interested to see what the isues were with workflows. 

     

    Event handler will fire reliably however you should take into account some potential issues. 

     

    When change to items are made by the system account then you will find that neithr workflow nor event handlers will fire. Your system account is the account running the application pool of your SharePoint web application.

     

    Also, when you are handling events you want to be careful. As long as you disable the event firing while you are dealing with the event then you should be ok for an event to fire only once.

    • Deleted's avatar
      Deleted

      Pieter,

       

      Sorry about leaving off the version...we are using Sharepoint Online.

       

      We had a workflow on a document library set up to address the lack of "Edit only your own" capability in libaries. Everyone had permission to add to the library but when someone added a document the workflow changed the permissions so that only the person who uploaded it could edit it. We encountered issues where the workflow would sometimes not start which was not a could scenario. We addressed this with MS support and they waived some magic fairy dust on our Tenant and the issue seems to have stopped. Unfortunately, my confidence in workflows is not the best.

       

      We have used event receivers hosted in Azure and they seem to be more reliable but we have had scenarios where they have failed to fire as well but that mostly has to do with occasions where we upload documents in mass. We have to run a clean up job nightly that double checks for these cases.

       

      It sure would be nice if we could just default the column within a DS like we can in a folder.

       

      We are using 

      • Why don't you set the column on the document set and then let the documents inside each document set inherit that column value from the document set.
      • Deleted's avatar
        Deleted

        We have thought about that but would prefer that we do this upon file creation in the library. We may have to resort to this. 

Resources