共享点列表,可自动删除项目 [英] Sharepoint list that delete the item automatically

查看:66
本文介绍了共享点列表,可自动删除项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在sharepoint2013中有一个列表,该列表具有从到列(来自是开始日期, 是结束日期).我希望当日期大于结束日期时自动删除该项目.我该怎么办?

I have a list in sharepoint2013 that has from to columns (from is the start date and to is the end date). I want the item to be deleted automatically when the date is greater than end date. How can I do it?

推荐答案

您可以使用事件接收器"反对名单.在事件接收器内部,您可以放置​​检查大于日期的逻辑.

You can use the "Event Receiver" against the list. Inside the event receiver you can put the logic that check the greater than date.

示例代码未经测试,但逻辑相同,您可以写入Item Update事件,

Example code not tested, but the logic is the same, You can write into Item Update event,

SPListItem item = properties.ListItems
Date d1 = DateTime.Now;
Date d2 = item["EndDate"];

if ( d1 < d2)
item.Delete();


在此之后,尝试用一个具有虚拟值的项目更新该项目,然后查看结果.一旦开始工作,您就可以使用它来运行所有列表项.

After this try to update the item against one item with dummy value and see the result. Once it started to work, then you can use to run against all the list items.

这是它的主意.用数字格式创建新列.在日期表视图"中打开您的列表,在第一个项目中添加数字1,然后开始将其拖动到最后一个项目,我们将其用于excel.

Here is the idea for it. Create the new column with number format. Open your list in "DateSheet View" add the number 1 in the first item and start to drag it upto last items we do it for excel.

此操作将触发列表中的Item更新事件,并且逻辑应该起作用. 

This operation will trigger the Item updated event in your list and the logic should work. 


这篇关于共享点列表,可自动删除项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆