I have to compare the whole CSV file with SharePoint list items to get the result either SP list items and CSV items are same/equal or not and then do the CRUD operation on SP list to maintain the balanced csv items and SP list items. Thanks in Advance.
-
what is your question? what did you try so far?– GwnyCommented Aug 13, 2015 at 8:13
-
I have to compare the csv item with the SP list-item and then if the csv item does not available in the list then need to add that item to list and if list contains more items than the CSV items then need to delete SP list-items. If some changes are thre then need to update the List-item.– RamCommented Aug 13, 2015 at 10:58
-
so start scripting then :)– GwnyCommented Aug 13, 2015 at 11:28
-
Hello Gwny Thanks !!! I'd done with my task and used this approch to reach the goal. foreach ($row in $csv) { $CSVid = $row.ID [Microsoft.SharePoint.Client.List]$list = $web.Lists.GetByTitle($listName) $items = $list.GetItemById($CSVid) $context.load($items) try { $context.ExecuteQuery(); } catch { $ErrorMessage = $_.Exception.Message } Is it fine or have some another way to do the same ??– RamCommented Aug 14, 2015 at 5:11
-
no I think this is fine so far. now you need the part with comparing your fields and updating them– GwnyCommented Aug 14, 2015 at 6:41
Add a comment
|
2 Answers
Create a powershell script which reads the csv as input. Get the List items by id and check if they are equal to the information from your csv. If not, make an update on the item.
Do this for every item. If you need some powershell sharepoint references: http://www.itunity.com/article/completing-basic-operations-sharepoint-csom-api-powershell-1278
I'd done with this code
foreach ($row in $csv)
{
$CSVid = $row.ID
[Microsoft.SharePoint.Client.List]$list = $web.Lists.GetByTitle($listName)
$items = $list.GetItemById($CSVid)
$context.load($items)
}
try
{
$context.ExecuteQuery();
}
catch
{
$ErrorMessage = $_.Exception.Message
}