Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
    
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. –  Daniel Ziga Dec 27 '11 at 13:27

2 Answers 2

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()
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {

                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;
                            destinationItem.Update();
                        }
                        listDestination.Update();

                        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--)
                        {
                            itemsSource[contador].Delete();
                        }
                        listSource.Update();

                        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.

share|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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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