Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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);            }
   }
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted
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);            } 

}

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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