I have two Custom Lists (Timesheet and Weekly Timesheet). My requirement is if any item exceeds the time length (or days) in "timesheet" list for more than 7days then that item has to be copied (Moved) to "weekly timesheet" list.

I am Working this scenario in SharePoint 2010 and SPD 2010.

Can anyone help me achieve this?

  • This can be achieved by making a timerjob which can be set to run every day and in it you can check if the requirements are exceeded, and if so, move the item to the other list. – user2536 Dec 27 '11 at 13:27

in my case i use a .NET Console Application, and run in my SharePoint Server like a Windows Task, daily.

This is the .NET Code:

private static void CopyListItems()

                using (SPSite site = new SPSite("http://server"))
                    using (SPWeb web = site.OpenWeb())
                        web.AllowUnsafeUpdates = true;
                        SPList listSource = web.Lists["Source Custom List"];

                        SPList listDestination = web.Lists["Destination Custom List"];
                        SPQuery query = new SPQuery();
                        query.Query = "<Where><Lt><FieldRef Name='Expires' /><Value IncludeTimeValue='FALSE' Type='DateTime'><Today /></Value></Lt></Where>";

                        SPListItemCollection items = listSource.GetItems(query);
                        foreach (SPListItem item in items)
                            SPListItem destinationItem = listDestination.Items.Add();
                            destinationItem["Title"] = item.Title;

                        SPQuery querySource = new SPQuery();
                        querySource.Query = "<Where><Lt><FieldRef Name='Expires' /><Value IncludeTimeValue='FALSE' Type='DateTime'><Today /></Value></Lt></Where>";
                        SPListItemCollection itemsSource = listSource.GetItems(querySource);
                        int total = itemsSource.Count - 1;
                        for (int contador = total; contador >= 0; contador--)

                        web.AllowUnsafeUpdates = false;

                } from 

A CAML code compare a Lower Than with Today function the Expires Field from Custom List source. And repeat the query to DELETE the items from Custom List Source.

| improve this answer | |
  • Thanks Andres,Actually iam trying this with Workflows in sharepoint designer 2010..Is it possible to do this scenario using WF through SPD 2010. – Naresh Nemuri Dec 30 '11 at 8:53

Using an SPD workflow, you could automatically fire a workflow upon item creation. This workflow can be set to immediately pause for 7 days. Upon resuming, you can check to see if your item's conditions meet your criteria for your Weekly List. Then you can copy it over using SPD as well.

That should work, but I'm thinking you'll need to base your condition off something other than Created b/c that would move all of your items over. If you need more help thinking it through, feel free to post back.

| improve this answer | |

I'm quite new to SharePoint, so I'm not sure if this works in 2010, but I just developed exactly something similar for Sharepoint 2013 with REST and CSOM ny Javascript:

Here es a method to create a list item (even in another site collection)

function createListItem = function(siteURL, listNameSTR, propertiesOBJ, successFUN)
    var ctxOBJ = new SP.ClientContext(siteURL);
    var listOBJ = ctxOBJ.get_web().get_lists().getByTitle(listNameSTR); 
    var itemOBJ = listOBJ.addItem(new SP.ListItemCreationInformation());    

    for(var propertySTR in propertiesOBJ) {
        itemOBJ.set_item(propertySTR, propertiesOBJ[propertySTR]);
        Function.createDelegate(this, successFUN), 
        Function.createDelegate(this, function(senderOBJ, argsOBJ){console.log(argsOBJ.get_message() + "\n" + argsOBJ.get_stackTrace());})

And here you read a given list and copy the items to another one (you simply could add your time length filter in the REST URL):

var restURL = '/_api/web/lists/getbytitle(\'YOUR_SOURCE_LIST\')/items?$filter=YOUR_FILTER;
    url: restURL,
    method: "GET",
    headers: {
        "Accept": "application/json; odata=verbose",
        "content-type": "application/json;odata=verbose",
        "X-RequestDigest": $("#__REQUESTDIGEST").val()

    success: function(jsonData){
        for (var i = 0; i < jsonData.d.results.length; i++) {
            var propertiesOBJ = {
                Title: jsonData.d.results[i].Title,
                //other properties...
            csTeamPlus.createListItem('YOUR_TARGET_SITE_COLLCTION', 'YOUR_TARGET_LIST', propertiesOBJ, function() {console.log('Success')});                    
            console.log('Copied Task: ' + jsonData.d.results[i].Title);
    error: function(data){
        console.log("An error occured..." + data.responseText);
| improve this answer | |

Here is the best solution to do it.

You can use retention policy.

In designer create a workflow in your timesheet custom list as

move current item to weekly timesheet Then stop workflow

Save and publish workflow

Then follow these steps:

  1. Go to your timesheet custom list
  2. Click on list (From the menu)
  3. Click on List setting
  4. click on Information Management policy
  5. Click on your policy and name it as you wish
  6. Check enable retention policy
  7. select completed and enter your desire days you want your item will move and in last box select days
  8. Next select run the workflow and select the work flow you created.
  9. Enable re-occurrence if you need it to make automatically to run.
  10. Click on ok
  11. Run Information Management Policy timer Jon and Expiration policy timer job.

after both job completes you can see your data will move to your desired list.

Hope this will resolve your issue.

Find the link for more https://blogs.msdn.microsoft.com/ecm/2011/10/12/policy-and-retention-in-sharepoint-server-2010/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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