Am trying to perform a basic insert to custom list item when an item added from sub-site source list but the insert command don’t execute. Any idea?
Elememnts.xml
setting to hook the receiver:
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Receivers ListUrl="Support/Lists/Suggestions" Scope="Web"> <Receiver> <Name>EventRcvr_MPW_SuggestionItemAdding</Name> <Type>ItemAdding</Type> <Assembly>$ SharePoint.Project.AssemblyFullName$ </Assembly> <Class>PortalV2.EventRcvr_MPW_Suggestion.EventRcvr_MPW_Suggestion</Class> <SequenceNumber>10000</SequenceNumber> </Receiver>
Insert code:
public override void ItemAdded(SPItemEventProperties properties) { base.ItemAdded(properties); this.EventFiringEnabled = false; //prevent multiple insert using (SPWeb web = properties.OpenWeb()) { SPList list = web.Lists["MyPortalWinner"]; web.AllowUnsafeUpdates = true; SPListItem item = list.Items.Add(); item["Title"] = "SUGGESTION"; item.Update(); web.AllowUnsafeUpdates = false; } this.EventFiringEnabled = true; //reset }