sharepoint 2019 event receiver is not firing

Raja 21 Reputation points
2021-01-10T23:29:55.107+00:00

We have a provider hosted app deployed which used to upload/ modify/ delete documents into document library. We have deployed a ItemDeleting event receiver (not RER) into document library. Event receiver is not firing when the item is deleted from provider hosted app web however it works if any document is getting deleted directly from SharePoint library. Would like to know why the event is not getting fired when the item is deleted from app web?

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,676 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,576 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jerryzy 10,566 Reputation points
    2021-01-11T06:02:06.96+00:00

    Hi @Raja ,

    I tested with the code snippet below to delete a file item in host web from Provider Hosted Add-in:

    private void DeleteItem(int id)
    {
    try
    {
    var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

    using (var context = spContext.CreateUserClientContextForSPHost())
    {

    Web web = context.Web;

    List oList = web.Lists.GetByTitle("Doc3");

    Microsoft.SharePoint.Client.ListItem oListItem = oList.GetItemById(id);

    oListItem.DeleteObject();

    context.ExecuteQuery();

    }
    }
    catch (Exception ex)
    {
    throw ex;
    }
    }

    It's triggering ItemDeleting event by debugging with break point:

    55201-snipaste-2021-01-11-13-51-06.png

    I suggest you can try to debug Event Receiver with break point to see if it triggered event or not.

    And here is a reference to access host web data in Provider hosted add in for your reference:

    Accessing SharePoint Data from Provider-Hosted Apps: Use the Right Context

    Thanks
    Best Regards


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful