Wednesday, August 28, 2013

Programmatically copy items from one list to another in SharePoint 2010


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using System.Collections;

namespace Console
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://serverName/sites/Vijai/"))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList sourceList = web.Lists.TryGetList("Test");
                    foreach (SPListItem sourceItem in sourceList.Items)
                    {
                        SPList destinationList = web.Lists.TryGetList("CopyTest");
                        if (destinationList != null)
                        {
                            SPListItem destItem = destinationList.Items.Add();
                            foreach (SPField field in sourceItem.Fields)
                            {
                                if (!field.ReadOnlyField && !field.Hidden && field.InternalName != "Attachments")
                                {
                                    if (destItem.Fields.ContainsField(field.InternalName))
                                    {
                                        destItem[field.InternalName] = sourceItem[field.InternalName];
                                    }
                                }
                            }
                            destItem.Update();
                        }
                    }                  
                }
            }
        }
    }
} 

Moving List Items from one list to another list in SharePoint 2010

We can move list items from one list to another list using standard SharePoint user interface. Here is the simple way to move items from one list to another in SharePoint 2010.
 
  1. Browse to the source list, click List tab on the ribbon bar and click List Settings icon.
     
  2. Click “Save list as template” link that exists under Permission and Management section which will bring up another page where you need to provide template File Name, Template name and Template Description. Make sure you didn’t check “Include Content” checkbox. Then, click the OK button.
     
  3. Go to Site Actions --> More options --> Click List under Filter By section. You can see the template which has been created in the previous step as part of other templates on the right pane. Choose the template and provide list name.
     
  4. If there are any workflows associated with the existing list that may still persist on the newly created destination list. Usually when lists are saved as template, all workflows associated to the original list will be saved as part of template except currently running workflows. Make sure all workflows associated with the original list have been removed if it’s not required. To remove workflows associated to list, go to List Settings Click on Workflow Settings Click “Remove a workflow” link, choose Remove option and click OK button.
     
  5. Open New (destination) List, Go to Site Actions --> Manage Content and Structure, choose the Original List on the left pane.
     
  6. You can increase the currently showing items up to 1000, sort list items by clicking column header and choose all items by clicking Select All option (displyaed top-left corner on the header) or individual items can be selected by clicking the checkbox displayed on each individual item.
     
  7. Click “Actions” --> Move and choose the target list (newly created destination list from template) on the popup.
     
  8. Finally click the OK button and wait until the list items are moved to destination list. If required, follow step 5, 6 & 7 until you moved the required list items to destination list.

The components for the 64-bit debugger are not registered. Please repair your Visual Studio 2008 Remote Debugger installation via 'Add or Remove Programs' in Control Panel.

To resolve this issue, you will need your Visual Studio 2008 installation disk. On this disk, you will find the following path -


Open visual Studio 2008 Setup and search inside that ..\Remote Debugger\x64\rdbgsetup.exe

A little surfing and I found a solution. Install the debugger! The 64-bit debugger is not installed by default. The installer is on the Visual Studio install disc. “<Drive Letter>\Remote Debugger\x64\rdbgsetup.exe”