Conflict when uploading and editing a field of a file in Sharepoint

2

I've been with this problem for days and as much as I've tried everything I've read, nothing works for me.

When uploading a file to a Sharepoint library, I try to fill one of its metadata through a development. In doing so I get a conflict error of saving the file. The code is as follows:

public override void ItemUpdated(SPItemEventProperties properties)
{
    base.ItemUpdated(properties);

    if (properties.List.Title.Equals("Process"))
    {
        EventFiringEnabled = false;

        string numExped = "0001";
        properties.ListItem["ExpedNumber"] = numExped;
        properties.ListItem.Update();

        EventFiringEnabled = true;
    }       
}

I've tried a thousand things, from putting SystemUpdate instead of Update. Also put a false as a parameter to the Update. Remove and put the EventFiringEnabled. Instance an item instead of using the properties.ListItem .

But nothing, when I enter the metadata and pulse protect, I always get this error:

The file is saved but remains unprotected. Can someone tell me what I'm doing wrong? Thanks, best regards;)

    
asked by Ramon 29.08.2018 в 10:56
source

1 answer

0

And if you try like this:

public override void ItemUpdated(SPItemEventProperties properties)
{
    base.ItemUpdated(properties);

    using (DisabledEventsScope scope = new DisabledEventsScope())
    {
        if (properties.List.Title.Equals("Process"))
        {
            EventFiringEnabled = false;

            string numExped = "0001";
            properties.ListItem["ExpedNumber"] = numExped;
            properties.ListItem.Update();

            EventFiringEnabled = true;
        }
    }
}
    
answered by 14.09.2018 в 17:47