I have 2 lists as follows:

List A has items grouped by 'category' and a column 'time'

List B has the total time sumed up for each category, based on items of List A.

The functioning is this: when an item is added or edited in list A, an iterator goes thru the list and sums up the time columns of those item that belong to the same class. After this sum, List B Total Column is updated with the new value.

I can't get to work this when an item is deleted/deleting. the best I can do is to use ItemDeleting, but only when I delete via the context menu. If I open the item and choose delete from the ribbon, sharepoint hangs and then times out.

This it the method I use

    public override void ItemDeleting(SPItemEventProperties properties)

            //using (DisabledEventsScope scope = new DisabledEventsScope())
                //gets the category
                String contrato = properties.ListItem["Contrato"].ToString();
                int minutosDescontar = Convert.ToInt32(properties.ListItem["Minutos"].ToString());
                int contratoID = calculaContratoID(contrato);

                //calls method to iterate and count values from items that belong to category
                int minutosGastosContrato = contabilizaAssistenciasContrato(contratoID, minutosDescontar);

                //updates listB with calculated totaltime
                atualizaMinutosContrato(contratoID, minutosGastosContrato);
        catch { Exception e; }


If i use ItemDeleted i lose the values, and although both deletion actions work, the total sum is not made correctly.

Any help, hint would be appreciated, thanks David

  • 1
    on the deleted event you loose the values on properties, but you should get them in to beforeProperties. – Marco Nov 11 '16 at 17:52
  • "If I open the item and choose delete from the ribbon, sharepoint hangs and then times out." What do you mean here? ItemDeleting doesn't work for you when you are using forms? That's strange I would say. – Sergei Sergeev Nov 11 '16 at 18:02
  • are you tried to debug it ? may be the issue at contabilizaAssistenciasContrato , atualizaMinutosContrato should you also update your answer with this functions ? – Mohamed El-Qassas MVP Nov 11 '16 at 18:57
  • the functions are ok, although the deleted vs deleting causes some issues. I thought i could pass my values to static variables upon the deleting action, and then get them back on the deleted method. I can populate the values, but the deleted method is not doing what is supposed to. – David Barroco Nov 15 '16 at 16:27
  • itemdeleting{ base.itemdeleting(properties); var1=X; var2=Y; } <- works – David Barroco Nov 15 '16 at 16:30

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.