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();
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.
An emerge a guarantee informatica training in chennai of gratefulness is situated hadoop training in chennai up for this instructive post.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteGreat content. I really enjoyed while reading this content with useful information, keep sharing.
ReplyDeletemvc training in chennai
Thanks for your informative post on selenium automation testing tool.
ReplyDeleteoracle scm training in chennai