3

I am trying to find the differences between Server-Side event receivers and Remote Event Receivers. now in server-side event receivers i can achieve following scenario:-

  1. Check if the user who is Adding or Updating the item is inside certain security group
  2. and if the user is inside this security group, he can add or edit the item,
  3. while if the user is NOT inside this security group,to cancel the Adding or Editing operation.

so generally speaking does Remote Event Receiver support the above scenario, as in the server side remote event receiver case? in other words can i inside remote ER check the current user membership (if the user is defined inside certain security group) and cancel the Adding or Editing operations accordingly ? Thank

2
  • Have you tried it? Commented Jan 22, 2018 at 2:40
  • @DerekGusoff to be honest i did not create any RER before.. and now i am preparing a document for one of our customers listing the limitations they might face if they want to migrate their SharePoint on-premises sites to be inside office 365.. so i am not sure if RER will be able to achieve what they are currently doing inside the server-side ERs?? i mean will the RER have any limitations compared to server-side ER??
    – user73206
    Commented Jan 22, 2018 at 12:31

1 Answer 1

0

Yes, We can.

We can use [SPRemoteEventResult.CancelWithError] or [SPRemoteEventResult.CancelNoError] to achieve it.

Here is a simple demo for your reference:

    public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
    {
        SPRemoteEventResult result = new SPRemoteEventResult();

        result.Status = SPRemoteEventServiceStatus.CancelNoError;
        result.Status = SPRemoteEventServiceStatus.CancelWithError;

        using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
        {
            if (clientContext != null)
            {
                clientContext.Load(clientContext.Web);
                clientContext.ExecuteQuery();
            }
        }

        //result.Status = SPRemoteEventServiceStatus.CancelNoError;
        result.Status = SPRemoteEventServiceStatus.CancelWithError;
        result.ErrorMessage = "Hello World";
        return result;
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.