0

I'm encountering some problems updating some items in my Event Handler.

I have a Document Library in which I have folders, items and folder of content type PRATICA, which derives from folder and has the same attribute of the other items in the list.

So... The code I've written is invoked by an Event Handler and want to apply mods on all items under a certain folder..

This works for items (like files etc). When it analize a SubFolder and find it of the right content type tries to modify the column but no modify has been applied (without exception and debugging every instruction is passed!!)

Any suggesion?

Thank you!

private void RecursiveUpdateItemCliente(SPFolder folder, string RagioneSociale, Guid fieldRS)
   {
       foreach (SPFile spfile in folder.Files) 
       {
           this.EventFiringEnabled = false;
           spfile.Item[fieldRS] = RagioneSociale;
           spfile.Item.SystemUpdate();
           this.EventFiringEnabled = true;
       }

       foreach (SPFolder spfolder in folder.SubFolders)
       {
           if ((spfolder.Name != "Forms") && (spfolder.Item.ContentTypeId.IsChildOf(new SPContentTypeId(PRATICA))))
           {
               this.EventFiringEnabled = false;
               folder.Item[fieldRS] = RagioneSociale;
               folder.Item.SystemUpdate();
               this.EventFiringEnabled = true;
           }
           RecursiveUpdateItemCliente(spfolder, RagioneSociale, fieldRS);            }
   }

1 Answer 1

0
private void RecursiveUpdateItemCliente(SPFolder folder, string RagioneSociale, Guid fieldRS) 
 { 
     foreach (SPFile spfile in folder.Files)  
   { 
       this.EventFiringEnabled = false; 
       spfile.Item[fieldRS] = RagioneSociale; 
       spfile.Item.SystemUpdate(); 
       this.EventFiringEnabled = true; 
   } 

   foreach (SPFolder spfolder in folder.SubFolders) 
   { 
       if ((spfolder.Name != "Forms") && (spfolder.Item.ContentTypeId.IsChildOf(new SPContentTypeId(PRATICA)))) 
       { 
           //I MUST GET SPFOLDER and NOT folder element...
           this.EventFiringEnabled = false; 
           spfolder.Item[fieldRS] = RagioneSociale; 
           spfolder.Item.SystemUpdate(); 
           this.EventFiringEnabled = true; 
       } 
       RecursiveUpdateItemCliente(spfolder, RagioneSociale, fieldRS);            } 

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.