Delete a work item from an event receiver
-
Saturday, May 05, 2012 7:29 AM
Icrandoatimerjobwith the classand ISPWorkItemJobDefinitiontheconditionin whichI believewith aEventReceiverto knowif there is aworkitemor moreto removequeuedbutnotlike knowingthatdirtrectamentewithsharepointand I amabout tomake astored procedurealthoughit is notallowedif I finda solutionI will have noother.
Annexthe method whereImake the conditionto see if thereeliminiarall itemsassociated with thatlist item.public override void ItemUpdated(SPItemEventProperties properties) { try { SPSite site = properties.OpenSite(); #region GetSchdDateTime Thread.CurrentThread.CurrentCulture = new CultureInfo("es-MX"); DateTime dateSendReminder = Convert.ToDateTime(properties.ListItem["FechaHoraEnvioNotificacion"]); DateTime dateCompare = Convert.ToDateTime(properties.ListItem["FechaHoraEnvioNotificacion"]); DateTime dateSend = new DateTime(dateCompare.Year, dateCompare.Month, dateCompare.Day, dateCompare.Hour, dateCompare.Minute, 00); DateTime getDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, 00); #endregion GetSchdDateTime Guid webId = properties.Web.ID; Guid listId = properties.ListId; int itemId = properties.ListItem.ID; Guid itemUniqueId = properties.ListItem.UniqueId; int currentUserId = properties.Web.CurrentUser.ID; in this part is where I need to do validation and go look for the database to see if there,delete it and create posterirmente
if (dateSend >= getDate) { SPSecurity.RunWithElevatedPrivileges(() => { try { site.AddWorkItem( Guid.NewGuid(), dateSendReminder.ToUniversalTime(), new Guid("1549D631-2711-464D-8FD6-CD643F0B44A7"), webId, listId, itemId, false, itemUniqueId, Guid.Empty, currentUserId, null, "FE_Timer_Notificaciones_ItemUpdated", Guid.Empty); }
Greetings and hopetoguide meandsupport mewith this part.thanks
All Replies
-
Monday, May 07, 2012 6:46 AMModerator
Hi Virus,
I’m not clear about your description, from the code you provide, do you mean that you want to delete a work item, if so, please refer to the following article about SPWorkflowItemCollection.DeleteWorkItem method to get more information about this:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spworkitemcollection.deleteworkitem.aspxIf it isn’t the issue, would you please provide more information about your requirement and describe it more clearly?
Thanks,
QiaoQiao Wei
TechNet Community Support
- Marked As Answer by Qiao WeiMicrosoft Contingent Staff, Moderator Thursday, May 17, 2012 9:29 AM

