Quick u Easy: Niżżel l-SPFolder ta 'SPListItem fi Receiver Event

Ddejjaqni li jammettu li, but I struggled with this one all day. My event receiver needs to update a field of its parent folder. This little bit shows how to do it:

privat null UpdateParentFolder(SPItemEventProperties proprjetajiet)
{

SPFolder thisItemFolder = properties.ListItem.File.ParentFolder;
thisItemFolder.Item["ZZ Approval Status"] = "Good news, kulħadd!";
thisItemFolder.Item.Update();


} // UpdateParentFolder

F'dan il-każ, Jien jaħdmu ma 'librerija dokument u l-proprjetajiet huma ġejjin minn avveniment ItemAdded.

Il-trick huwa li inti ma tistax tikseb l-SPFolder 'l-oġġett direttament mill-oġġett innifsu (I.E. properties.ListItem.Folder huwa null). Minflok, mur File assoċjati l-oġġett lista u jiksbu folder tal-fajl.

</aħħar>

Abbona għall-blog tiegħi!

Wieħed ħasbu dwar "Quick u Easy: Niżżel l-SPFolder ta 'SPListItem fi Receiver Event

Ħalli Irrispondi

Your email address mhux se jkun ippubblikat. Meħtieġa oqsma huma mmarkati *