0

I have set up a local development environment on sharepoint for the sake of testing event recievers.

I can build and deploy the following code.

However when I deploy the following code it does not change the document's title property when a file is uploaded.

 using System;
 using System.Security.Permissions;
 using Microsoft.SharePoint;
 using Microsoft.SharePoint.Utilities;
 using Microsoft.SharePoint.Workflow;

 namespace chrisclementen.chrisclementen
 {
/// <summary>
/// List Item Events
/// </summary>
public class chrisclementen : SPItemEventReceiver
{
    /// <summary>
    /// An item was added.
    /// </summary>
    public override void ItemAdded(SPItemEventProperties properties)
    {
        base.ItemAdded(properties);
        properties.ListItem["Title"] = "test synchro";
        properties.ListItem.Update();
    }

    /// <summary>
    /// An item was updated.
    /// </summary>
    public override void ItemUpdated(SPItemEventProperties properties)
    {
        base.ItemUpdated(properties);
        properties.ListItem["Title"] = "test synchro";
        properties.ListItem.Update();
    }


}
 }
1

1- Check the Element.xml of the Event Receiver and add the listUrl Attribute :

<Receivers ListUrl="Lists/YourListUrl"> // For simple Lists

or

<Receivers ListUrl="Documents"> //For Document Libraries

Edit :

You Element.xml should look like this. Please dont copy it from here just replace the List url in your Element.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListUrl="Lists/YourListUrl">
    <Receiver>
      <Name>chrisclementenItemAdded</Name>
      <Type>ItemAdded</Type>
      <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
      <Class>chrisclementen.....</Class>
      <SequenceNumber>10000</SequenceNumber>
      <Synchronization>Synchronous</Synchronization>
    </Receiver>
    <Receiver>
      <Name>chrisclementen ItemUpdated</Name>
      <Type>ItemUpdated</Type>
      <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
      <Class>chrisclementen.chrisclementen.Ichrisclementen </Class>
      <SequenceNumber>10000</SequenceNumber>
      <Synchronization>Synchronous</Synchronization>
    </Receiver>
  </Receivers>
</Elements>

if it still not working : Add this line like in the exemple.

<Synchronization>Synchronous</Synchronization>

Let me know if this was helpfull for you.

  • I have edited my answer. – Ahmed Bouchaala Sep 7 '18 at 9:40
  • :D Happy for you, Please mark the post as resolved ;) – Ahmed Bouchaala Sep 7 '18 at 9:46
  • Thank you again! You have resolved days of work. My only regret is I cannot give you more points. – dipl0 Sep 7 '18 at 9:54
  • You are welcome :) KEEP CALM AND SHAREPOINT !!! – Ahmed Bouchaala Sep 7 '18 at 9:57
  • If you can't give him more points, we can :), we really appreciate the good answers, keep it up :) – Mohamed El-Qassas MVP Sep 7 '18 at 13:58

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.