0

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.

1
  • I do have the same Requirement. i tried Like this but still unable to acheive the same. Canyou please help me on this Commented Jun 3, 2013 at 6:45

3 Answers 3

2

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:

  1. get list
  2. check if an item hasn't been modified since 365 days.
  3. move to other list
0

Look into information management policies. That is what they are designed to accomplish.

1
  • 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
    – Naresh
    Commented Aug 23, 2012 at 5:01
0

@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/

2
  • 1
    Do you mean "Scheduled task" for triggering it? Commented Aug 8, 2014 at 12:40
  • thats correct, I'll edit my answer
    – Plexus81
    Commented Aug 8, 2014 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.