How can i copy an item from one list to another list,I want to archive this item after 365 days of modified date of any item in the list.this i have to be do with Custom Timer job. can you please suggest how would i do this.
3 Answers
I suggest you to use google...
http://www.codeproject.com/Tips/634208/Create-and-Deploy-Custom-Timer-Job-Definition-in-S
Basically make a TimerJob in Visualstudio, write your code there and let this job run once a day.
Code:
- get list
- check if an item hasn't been modified since 365 days.
- move to other list
Look into information management policies. That is what they are designed to accomplish.
-
iam using sharepoint foundation 2010,as i know that there was no option of Information management policies in foundation..can u suggest through custom timer jobs– NareshCommented Aug 23, 2012 at 5:01
@Gwny have an pretty good answer but you could also manage it with Powershell.
"PowerShell: This is the best option when it comes to copying list in your SharePoint site. Here is what you need to do."
Get an instance of the SharePoint Site Collection using SharePoint SPSite object. Open the root web. Save the list that you want to copy as a template using SaveAsTemplate method of SPList. Get a reference to the list template that is created. Add a list using SPListCollection.Add Method (String, String, SPListTemplate). When successful, this method will display the list GUID. Update the root web using SPWeb.Update
The code below only copy the list, if you want to achieve only the items you have to check each item in the list.
#//Replace the URL with your real site collection URL
$siteURL = "http://sitecollectionURL"
#//Replace the list title with your list title in site collection
$sourceListTitle = "My List Title"
$targetListTitle = "My Target List Title"
$site = New-Object Microsoft.SharePoint.SPSite($siteURL)
$web = $site.OpenWeb()
$sourceList = $web.Lists[$sourceListTitle]
$sourceList.SaveAsTemplate($sourceListTitle,$sourceListTitle,$true)
$listTemplate = $site.GetCustomListTemplates($web)[$sourceListTitle]
$web.Lists.Add($targetListTitle, $targetListTitle, $listTemplate
Then set the Scheduled task to run each 365 day.
http://www.naumanahmed.com/2012/02/sharepoint-2010-how-to-copy-list-within.html
http://sergioblogs.blog.co.uk/2013/01/08/so-i-had-an-issue-at-work-where-i-needed-15407471/page/2/
-
1
-