0

I have create Remote Event Receiver on Item Adding, I want to restrict to create Folder in Document Library. It is working fine but my error message is not displaying.

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

            using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
            {
                if (clientContext != null)
                {
                    if (properties.EventType == SPRemoteEventType.ItemAdding)
                    {                        
                        try
                        {                          
                          //  string strQuery = curHttpContext.Request.QueryString["empid"];
                          //  WriteToLog("QueryString", strQuery, clientContext);
                          if (!properties.ItemEventProperties.AfterProperties.ContainsKey("vti_filesize"))
                            {
                                clientContext.Load(clientContext.Web);
                                clientContext.ExecuteQuery();
                                string errMsg = "Folder is not supported";
                                result.Status = SPRemoteEventServiceStatus.CancelWithError;
                                result.ErrorMessage = errMsg;
                            }
                            
                        }
                        catch(Exception ex)
                        {                           
                                WriteToLog("Exception",ex.Message,clientContext);                            
                        }
                    }
                }
                return result;
            }

        }

Can anyone give me snippet for access the query string parameter in Remote Event Receiver for Item Adding Event.

Your Answer

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

Browse other questions tagged or ask your own question.