Interview Questions administrator

Best SharePoint administrator Interview Questions and Answers with topic wise:


Recycle Bin | MMS | ManagedVsCrawledProperties |

Thursday, January 15, 2015

Copy/Move items from one list to another list in sharepoint

Scenario:
List AA fields: Name, Title, User Name, Religion, Qualification.
List BB fields: Name, Title, User Name, Qualification, Designation, Salary and Description
Common field names: Name, Title, user name, Qualification
Now, I want to copy the common field values from List AA to List BB.

Approach:
//Read the list item values by ID and add the common field values as new item into the another list
SPListItem spLstItemsAA = listNameAA.GetItemById(ItemID); //ItemID of List AA
SPListItem spLstItemBB = list.Items.Add();
foreach (SPListItem spLstItemAA in spLstItemsAA.ListItems)
{
       for (int i = 0; i < spLstItemAA.Fields.Count; i++)
       {
          if ((!spLstItemBB.Fields[i].Hidden) && (!spLstItemBB.Fields[i].ReadOnlyField) &&    
                                  !(customfields.Contains(item.Fields[i].Title)))
           {
               spLstItemBB [item.Fields[i].Title] = spLstItemAA [item.Fields[i].Title];
             }
        }
 }
 spLstItemBB ["Salary"] = "50k";
spLstItemBB ["Description"] = "sharepointquicksolutions.blogspot.in ";
spLstItemBB.Update();

Condition#1: !spLstItemBB.Fields[i].ReadOnlyField
Condition#2: !spLstItemBB.Fields[i].Hidden
The above 2 conditions are used for to skip the read only and hidden fields.

Note: By default, every sharepoint list and library will have the below fields.


4 comments:

  1. An emerge a guarantee informatica training in chennai of gratefulness is situated hadoop training in chennai up for this instructive post.

    ReplyDelete
  2. Great article, thanks for sharing helpful information, I tested this Migrator for Documents
    tool ( http://www.lepide.com/lepidemigratordocuments/ ) that assists to move ove Documents from One Library to Another in SharePoint 2013 and migrate public folder to SharePoint instantly. This Migration tool provides an easy way for system administrator to execute task of SharePoint server migration.

    ReplyDelete
  3. Great content. I really enjoyed while reading this content with useful information, keep sharing.
    mvc training in chennai

    ReplyDelete
  4. Thanks for your informative post on selenium automation testing tool.

    oracle scm training in chennai

    ReplyDelete