I have two calendars, I created workflow that creates item to second calendar when item created in first calendar. in second calendar i created column 'Id odsustvo' where the workflow set item id of first list. I tryed that create event receiver, but he is not working. i cannot delete item in second list when is deleted item in first list. code is next
- using System;
- using System.Security.Permissions;
- using Microsoft.SharePoint;
- using Microsoft.SharePoint.Security;
- using Microsoft.SharePoint.Utilities;
- using Microsoft.SharePoint.Workflow;
- namespace brisanje_stavke_iz_karneta_eventreceiver.EventReceiver1
- {
- ///
- /// List Item Events
- ///
- public class EventReceiver1 : SPItemEventReceiver
- {
- private static string ID;
- ///
- /// An item is being deleted.
- ///
- public override void ItemDeleting(SPItemEventProperties properties)
- {
- base.ItemDeleting(properties);
- ID = properties.ListItem["ID"].ToString();
- }
- ///
- /// An item was deleted.
- ///
- public override void ItemDeleted(SPItemEventProperties properties)
- {
- string ID1 = ID;
- int IDConverted = Convert.ToInt32(ID1);
- SPSite ListSite = new SPSite(properties.Web.Url);
- SPWeb ListWeb = ListSite.OpenWeb();
- SPQuery query = new SPQuery();
- query.Query = "
" + - "
" + - "
" + - "
ID1Converted" + - "" +
- "";
- SPListItem KarnetItem = ListWeb.Lists["Karnet"].GetItems(query)[0];
- KarnetItem.Delete();
- base.ItemDeleted(properties);
- }
- }
- }
I noticed that my code deletes an item from calendar view of the second list, but not from all items view. why?
Some guide for my help?
Nanddeep NachanPosted Oct 3, 2018, 2:19 AM