update created by and modified by fields in sharepoint using client object model

update created by and modified by fields in sharepoint  using client object model
In this article we can able to see, how to update the created by and modified user name using client object model.
We migrated a site from lotus notes to SharePoint for those items user name is coming as current system login user name, that to SharePoint site is in different environment, we are unable to do using PowerShell, so we done a sample client side object model to update the created by and modified by user names.

 Import Data from excel to SharePoint List using PowerShell
 How to add fields to list in sharepoint using powershell 
Copy value from one filed to another field using PowerShell - See more at: http://www.dotnetsharepoint.com/2015/07/copy-value-from-one-filed-to-another.html#sthash.QPHZ7Tjz.dpuf
 Copy value from one filed to another field using PowerShell 
Date formula in SharePoint calculated value
 Date formula in SharePoint calculated value 

using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace updatecreatedby
{
    class Program
    {
        static void Main(string[] args)
        {
            ClientContext clicon = new ClientContext("http://dotnetsharepoint.com/sites/SharePoint");
            SP.List list =clicon.Web.Lists.GetByTitle("yourlistname");
            clicon.Load(list);
            SP.ListItem item = list.GetItemById(22); //here item ID updating a single item
            clicon .Load(item);
            item["Author"] = GetUsers(clicon, "domainname\\createdname ");
            item.Update();
            item["Editor"] = GetUsers(clicon, " domainname\\modifiedname ");
            item.Update();
            clicon.ExecuteQuery();
       
        }

        private static SP.FieldUserValue GetUsers(ClientContext clientContext, string UserName)
        {
            SP.FieldUserValue userValue = new SP.FieldUserValue();
            SP.User updateUser = clientContext.Web.EnsureUser(UserName);
            clientContext.Load(updateUser);
            clientContext.ExecuteQuery();
            userValue.LookupId = updateUser.Id;
            return userValue;
        }

    }
}


SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

Import Data from excel to SharePoint List using PowerShell

In this article we are able to show how to import CSV excel data in to SharePoint List, some time we have to Import large amount of information from excel CSV to SharePoint list for this we can use PowerShell script, we created a list with name "ImportCSVData" with three fields Year,MovieName,HeroName.
 How to add fields to list in sharepoint using powershell 
Copy value from one filed to another field using PowerShell - See more at: http://www.dotnetsharepoint.com/2015/07/copy-value-from-one-filed-to-another.html#sthash.QPHZ7Tjz.dpuf
Copy value from one filed to another field using PowerShell 
Date formula in SharePoint calculated value
 Date formula in SharePoint calculated value 

Excel will looks like this

$info = Import-CSV ‘D:\ImportData.csv' -header("Year", "MovieName","HeroName")
$web = Get-SPWeb -Identity "http://dotnetsharepoint.com/sites/sharepoint2013/importdata"
$list= $web.Lists["ImportCSVData"]
foreach ($rows in $info )
{
    $item = $list.Items.Add();
    $item["Year"] = $rows.Year
    $item["MovieName"] = $rows.MovieName
    $item["HeroName"] = $rows.HeroName
    $item.Update()
}
Write-Host "Excel information Updated successfully in to List"
$web.Dispose()

How to update the modified by using power shell
How to create topic for discussion board in sharepoint using powershell

SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

Add X years to date column based on item created date in SharePoint PowerShell

Add X years to date column based on item created date in SharePoint PowerShell
 We are having a requirement to update +3Years  date value based on item created date for all the existing items in the SharePoint list without modifying the  created by and modified by values, we can achieve this using PowerShell.
How to add fields to list in sharepoint using powershell - See more at: http://www.dotnetsharepoint.com/2015/07/how-to-add-fields-to-list-in-sharepoint.html#sthash.ctSnqWrY.dpuf
 
 How to add fields to list in sharepoint using powershell 
Copy value from one filed to another field using PowerShell - See more at: http://www.dotnetsharepoint.com/2015/07/copy-value-from-one-filed-to-another.html#sthash.QPHZ7Tjz.dpuf
Copy value from one filed to another field using PowerShell 
Date formula in SharePoint calculated value
 Date formula in SharePoint calculated value
Date formula in SharePoint calculated value
Date formula in SharePoint calculated value
Date formula in SharePoint calculated value
Date formula in SharePoint calculated value
Date formula in SharePoint calculated value
Copy value from one filed to another field using PowerShell - See more at: http://www.dotnetsharepoint.com/2015/07/copy-value-from-one-filed-to-another.html#sthash.QPHZ7Tjz.dpuf
Copy value from one filed to another field using PowerShell - See more at: http://www.dotnetsharepoint.com/2015/07/copy-value-from-one-filed-to-another.html#sthash.QPHZ7Tjz.dpuf
Copy value from one filed to another field using PowerShell - See more at: http://www.dotnetsharepoint.com/2015/07/copy-value-from-one-filed-to-another.html#sthash.QPHZ7Tjz.dpuf
Copy value from one filed to another field using PowerShell - See more at: http://www.dotnetsharepoint.com/2015/07/copy-value-from-one-filed-to-another.html#sthash.QPHZ7Tjz.dpuf
Copy value from one filed to another field using PowerShell - See more at: http://www.dotnetsharepoint.com/2015/07/copy-value-from-one-filed-to-another.html#sthash.QPHZ7Tjz.dpuf
How to add fields to list in sharepoint using powershell - See more at: http://www.dotnetsharepoint.com/2015/07/how-to-add-fields-to-list-in-sharepoint.html#sthash.ctSnqWrY.dpuf

Copy value from one filed to another field using PowerShell - See more at: http://www.dotnetsharepoint.com/2015/07/copy-value-from-one-filed-to-another.html#sthash.QPHZ7Tjz.dpuf
How to add fields to list in sharepoint using powershell - See more at: http://www.dotnetsharepoint.com/2015/07/how-to-add-fields-to-list-in-sharepoint.html#sthash.ctSnqWrY.dpuf
How to add fields to list in sharepoint using powershell - See more at: http://www.dotnetsharepoint.com/2015/07/how-to-add-fields-to-list-in-sharepoint.html#sthash.ctSnqWrY.dpuf
How to add fields to list in sharepoint using powershell - See more at: http://www.dotnetsharepoint.com/2015/07/how-to-add-fields-to-list-in-sharepoint.html#sthash.ctSnqWrY.dpuf
$Web = Get-SPWeb -Identity http://dotnetsharepoint.com/sites/sharepoint/addyears

$List=$Web.Lists["YourListName"] 

 $items = $list.items

  #Go through all items

foreach($item in $items)

{

    $item["Your Column Name"] = $item["Created"].AddYears(3)

     $modifiedBy = $item["Editor"]

$modifieddate = $item["Modified"]

$item["Editor"] = $modifiedBy

$item["Modified"] = $modifieddate

$item.Update()

  }

  $list.Update()
 
SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

Copy value from one filed to another field using PowerShell

Copy value from one filed to another field using PowerShell


In this example we are showing how to copy values from one item to another item.

We are having a column with multi-level field type we are unable to do Group by for this field, so we planned to change the field type to text and copy the values from Multi type field to Single line of Text, best option to achieve this functionality is PowerShell
How to update the modified by using power shell
How to add fields to list in sharepoint using powershell
How to create topic for discussion board in sharepoint using powershell
 
 Add-PSSnapin Microsoft.Sharepoint.Powershell

    $web =  Get-SPWeb -Identity http://dotnetsharepoint.com/sites/sharepoint/copyitems

    $list =$web.Lists["ListName"]

    $items = $list.items

    foreach ($item in $items)

    {

    $sourcevalue = $item["SourceColumn"]

    $item["DestinationColumn"] = $sourcevalue

    write-host $sourcevalue

    $item.update()

    }

    $list.update()
Please let me know having any issues.
 SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

How to add fields to list in sharepoint using powershell

How to add fields to list in sharepoint using powershell

In this example we are able to show,how to add fields to list in sharepoint using powershell script.
Here list is already available,we are accessing the list and adding the Text Type column to the existing list,first it will check the condition weather that particular field is available in the list or not,if not available than only we can able to create the Field.

Add-PSSnapin Microsoft.SharePoint.PowerShell
#Get the Site URL
$weburl = Get-SPWeb "http://dotnetsharepoint.com/sites/SharePoint/SharePoint2013"
#Get the List Name
$list = $weburl.lists["YourListName"]
#check condition field is available or not
if($list.Fields.ContainsField("YourColumnName") -eq $true)  {
      Write-Host  "FieldName already avilable in the List"
 }
 else
 {
 #Add New Text type field to the list

$SPFieldType = [Microsoft.SharePoint.SPFieldType]::Text
$list.Fields.Add("YourColumnName",$SPFieldType,$false)
$list.update()
}

SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

How to import users from CSV to SharePoint site using PowerShell

Here we are showing how to import users from csv to SharePoint site using PowerShell, In some cases we have users available in the document or in notepad, we have to add those users into SharePoint group, adding 2 or 3 users manually is not a problem but adding 50+ users it will take lot of effort for a user to add in to SharePoint site.


For this using PowerShell we can add it easily, check the below code snippet and excel with CSV format looks.

Add-PSSnapin Microsoft.SharePoint.PowerShell
$UserinfoCSV = "C:\DotNetSharePoint\ImportUsers.csv"
 # Import the CSV file
#In CSV there are no headers,CSV having two columns values  one is SP group name and another one is username.
$UserInfo = Import-CSV $UserinfoCSV -header("GroupName","UserAccount")
#Get the Web
$Web = Get-SPWeb http://dotnetsharepoint.com/sites/sharepoint/importusers
 #looping each user from CSV file
foreach ($user in $UserInfo)
{
       $Group = $web.SiteGroups[$User.GroupName]
    $User = $web.Site.RootWeb.EnsureUser($User.UserAccount)
    $Group.AddUser($User)
     }
 $Web.Dispose()


SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

There was an exception running the extensions specified in the config file

While we doing the migration from lotus notes to SharePoint we got the error as shown below.

Error adding attachment name.csv there was an exception running the extension specified in the config file->maximum request length exceededà there was an exception running the extensions specified in the config file-> Maximum request length exceeded  


We have to change the options at three places
1) We have to verify in the tool
We have to make this as empty as shown below.
2) On that particular web application in General setting we have to change the value as per your limit.
3) We have to change the Size in the Webconfig file size for a particular web application that you want to change the size of the web application
Search for httpRuntime and change the value as shown below as per requirement size limit 


While doing all these steps next time you wont get this type off error  :)

SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

How to update the modified by using power shell

How to update the modified by using power shell
In this example I want to show how to update the modify by and modified date using PowerShell.
Sometimes it may happen that exiting item or items we need to update with the user name instead of our name, for that we can achieve using power shell easily.

Here I am updating the Last modified name and the date with name for a particular items based on the item ID.

$web = Get-SPWeb http://dotnetsharepoint.com/sites/dotnet/sharepoint2013
$list = $web.lists["UpdateModified"]
#23 is my item id,i am update for a particular item only
$item = $list.items.getitembyid(23)
$username = $Web.EnsureUser(domain/username)
$item["Editor"] = $username
$item["Modified"] = "7/17/2015 8:00 AM"
$item.Update()
$list.Update()
$web.Dispose()

SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

How to create topic for discussion board in sharepoint using powershell

In this article we can able to see how we can create a new topic for a discussion board list using PowerShell.


#get the site URL
$web=Get-SPweb http://dotnetsharepoint.com/sites/SharePoint/SharePoint2013
#get the List name
$list=$web.Lists["ListName"]
#Check weather the list is availbale or not
if($list -ne $null)
{
#Creating a new discussion
$newTopic = [Microsoft.SharePoint.Utilities.SPUtility]::CreateNewDiscussion($list, "Welcome to DotnetSharePoint");
$newTopic["Body"] = "We hope our site is very usefull to learn new things!";
$newTopic.Update();
Write-Host $newTopic.Title " discussion board topic is created successfully"
}
else
{
Write-Host "List does not exists!"
}


Output:

SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

How to add column in to List using Power Shell

In this Post we are able to show, how to add the “Multi Choice” column   to the Particular list and also we can check the condition that column is available in that list or not.
In our Example we created a List with Name “SharePoint List” using power shell created a column and adding the Values.

Add-PSSnapin Microsoft.SharePoint.PowerShell
#Get the Site URL
$weburl = Get-SPWeb "http://dotnetsharepoint.com/sites/SharePoint/SharePoint2013"
#Get the List Name
$list = $weburl.lists["SharePoint List"]
#check condition field is available or not
if($list.Fields.ContainsField("SharePoint") -eq $true)  {
      Write-Host  "FieldName already avilable in the List"
 }
 else
 {
 #Add New choice field to the list
$list.Fields.Add("SharePoint", [Microsoft.SharePoint.SPFieldType]::Choice,
$false)
#Add Choices to the field
$ChoiceField = $list.Fields.GetField("SharePoint")
#Get the field #Required Field
$ChoiceField.Required = $true
#Set Default value
$ChoiceField.DefaultValue = “SharePoint2013"
#Allow Fill-in Choices
$ChoiceField.FillInChoice = $false
#Add the Drop down choice values
$ChoiceField.Choices.Add("SharePoint2013")
$ChoiceField.Choices.Add("SharePoint2010")
$ChoiceField.Choices.Add("SharePoint2007")
#Commit changes
$ChoiceField.update()
$list.update()
}

OutPut:



SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

Date formula in SharePoint calculated value

In this article I want to show you to get the next 3 years date based on the today’s date, without using Script we can do it simply using the Calculated Value.

We are having a list with name “Date” with Column “Next3Years” and created the calculated value as shown below with settings.

=DATE(YEAR(Today)+3,MONTH(Today),DAY(Today))


We also change X years instead of 3 years based on your requirement.
While Creating new item we can able to see the column as shown below, if we want to change the date we can able to change and save the  item without any issues.
Finally it looks as shown below.




SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

Import values from Excel to SharePoint list using PowerShell


In this article we can able to see how to import values from Excel to SharePoint List.

In our scenario we are having a list “VirtoSoftware ” having a TOP 5  Third party we parts(VitroSoftware is a  company  they design and builds innovate we parts for Microsoft SharePoint)  instead of entering manually using Power Shell we can do it easily.

This is the Excel and the list, Excel having the Information but list is having no items.
Now I am running the below PowerShell Script as show below.
Add-PSSnapin microsoft.sharepoint.powershell
$excelinfo = Import-Csv -Path "D:\VirtoSoftware.csv" -Header("Title")
 $web = Get-SPWeb http://virtosoftware.com/sites/topwebparts
$list = $web.Lists["virtosoftware"] write-host $list
foreach ($row in $excelinfo) {
    if($row.Title -ne "" -and $row.Title -ne $null)
    {
    $item = $list.Items.Add();
    $item["Title"] = $row.Title;
          $item.Update();
      }
}
 Once it’s completed finally we can see the OUTPUT


SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM

Labels

.Net Interview Questions add custom button in sharepoint using javascript Add custom column property into a PageLayout in SharePoint Add Page Title on their browser's title bar in SharePoint Customly add zip files in blogger Add-SPOSiteCollectionAppCatalog : Must have Manage Web Site permissions or be a tenant admin in order to add or remove sites from the site collection app catalog allow list Advance SmartObject An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL. Angular 2 Angular JS Angularjs Angularjs 1 anonymous users accessing lists and libraries App Permissions for SharePoint 2013 asp.net membership unique email Asp.net TreeView Control asp.net. Attendees in SharePoint Auto refresh list using Content Editor WebPart in SharePoint 2013. Auto Refresh SharePoint list using JavaScript Block and unblock of attachment types in SharePoint Blogger C# Callouts in SharePoint 2013 Cascading Dropdown list in SharePoint change onenote to another location. change SuiteBarLeft in SharePoint 2013 check if userid exists in database c# click node text to expand/collapse in Treeview client object model Close webpart CQWP crate chart using BI site in PPS Create a modern team site collection in SharePoint online Create BI chart in PPS SharePoint 2013 create filter in dashboard designer. create kpi's in dashboard designer create kpi's in SharePoint 2013 dashboard designer Create List Create List In SharePoint Create List using Power Shell Script Create Lookup Field in List using Power Shell Script Create lookup field in List create SharePoint List custom view. create SharePoint List views in List Schema create site collection in site collection in SharePoint using powershell created Date Time calculated field in SharePoint Cross site Collection in SharePoint 2013 Crud Operation in Asp.net Using Stored Procedure Custom MasterPage Approval in SharePoint custom view for survey list Customly add SharePoint List view in Page. delete items in sharepoint using powershell Difference between Angular 1.x & Angular 2 difference between Office 365 and Windows Azure difference between Windows Azure and Office 365 in sharepoint? DifferenceBetween discussion board Display Data in Grid View display radio buttons and choice fields horizontally in SharePoint 2013 Document library DotNet Drag and drop documents in document library in SharePoint dynamically populating values from one list to another list using jquery in sharepoint edit and delete buttons in datagridview Edit Links email notification using Nintex enable anonymous access in SharePoint 2013 enable app catalog sharepoint online site collection powershell Enable appcatalog site collection level using PowerShell based on Input file Enable versions for list and library except the hidden lists using PowerShell Script Error occurred in deployment step 'Recycle IIS Application Pool': Cannot resolve model for the project package Errors&Solutions Export document library in sharepoint using powershell Export particular Group in Term Store Management in SharePoint 2013 Export to Excel first release Flow Flow features free disk space on servers using powershell Friendly URLs and Managed Navigation in SharePoint 2013 get a list of site collection with template in web application using PowerShell Script in SharePoint Get attachments in SharePoint custom list using c# get current list item id sharepoint programmatically Get current url using jquery Get data from SharePoint list using Rest api & Angular JS Get Random Get Random SharePoint items using PowerShell Get Random values from SharePoint list using PowerShell Get url of the last value using jquery Get-SPOSite : The managed path sites/yoursitename is not a managed path in this tenant. Getting Email From User Hide “Edit Links” in left navigation SharePoint 2013 hide button in sharepoint based on permissions Hide column in SharePoint List view hide fields using client side object model Hide list in Quick Launch in SharePoint using PowerShell How to add Custom Tiles to SharePoint site Page. How to add extension files in Search Navigation in SharePoint 2013 How to Add Multiple users Using SharePoint People Picker How to add SharePoint list view in Page using C# How to Approve MasterPage using PowerShell in SharePoint How to bind Multiple users Using SharePoint People Picker how to change indicators on kpi performance how to check if an email address already exists in the database in asp.net how to configure workflow manager platform for SharePoint 2013 how to create calculated value using powershell how to create certificate in SharePoint How to create flow. how to create gantt chart webpart in sharepoint how to create KPI indicators in Dashboard designer How to create moden communication site in SharePoint online How to create Multi selected filter in Dashboard How to create nintex workflow in sharepoint how to create rdlc reports in asp.net How to Display Data Grid View in ASP.net How to enable anonymous access in SharePoint How to find data in datagridview in c# How to get image names from the folder using C# how to get particular list content type id in SharePoint 2013 How to get QueryString value in SharePoint WebPart Programatically how to get the current item id for newly created item using REST API and JQuery how to hide list in sharepoint how to know who created list in sharepoint How to make a Site Collection Read-Only in SharePoint 2010 How to overlay Office 365 shared calendar on SharePoint Site how to pass jquery value to asp.net textbox control How to pass pagename as a browser's title bar in the page how to remove unused Application Pool in SharePoint how to remove zone using powershell script How to send mail to particular group of people using PowerShell how to update modified by and created by using powershell how to uplaod RAR files in blogger import csv data into sharepoint import data using powershell Import group to term store management using SharePoint 2013. InfoPath InfoPath Cascading Dropdown list Insert update delete in datagridview in C# winforms Integration from SharePoint to k2. K2 Smart Forms for SharePoint JavaScript Injection jquery JSON K2 blackpearl K2 Designer K2 Designer Workflow. K2 smartform cascading dropdown list k2 Workflow K2 workflow to send a mail with PDF left navigation Local Term Set in managed meta data Managed meta data navigation in SharePoint 2013 Managed metadata service in SharePoint 2013. Managed Navigation in SharePoint 2013. Managed Promoted Sites. meta data navigation Microsoft Flow New Features New-SPConfigurationDatabase The user does not exist or is not unique NintexWorkFlow Office 365 OneDrive OneNote overwrite existing document in sharepoint using javascript PDF Converter PDF Method in K2 Performance Point Service in SharePoint 2013 PerformancePoint Services Configurtion PerformancePoint Services Configurtion for SharePoint 2013 PerformancePoint Services in SharePoint Server 2013 Popularity trends in SharePoint 2013 Pages populate dropdown list dynamicallyusing jquery Power Power Automate Power Shell Power shell script to get SharePoint site size. PowerApps powershell read xml PowerShell Script PowerShell script to get list of users from SharePoint groups PowerShell Scripts in SharePoint 2013 Powershell to set the masterpage in SharePoint Promoted Links Promoted Sites psconfig.exe quick launch Rdlc reports Readonly Column in SharePoint Editview Realtime DotNet Interview Questions Recent Dotnet interview questions Recent SharePoint interview questions recover deleted OneNote page. OneNote content is missing Regional Settings in SharePoint 2013 Replace New Item text in SharePoint Rest API Schedule PowerShell Script Search in SharePoint 2013 Search navigation in SharePoint 2013 Secure store service SecureStore Services SecureStore Services configuration for SharePoint 2013 self-signed certificate on IIS Server Send email to members of SharePoint Group using PowerShell sharepint2010 sharepoin2010 SharePoint 2013 SharePoint 2010 SharePoint 2013 SharePoint 2013 Dashboard Designer SharePoint 2013 features SharePoint 2013 Interview Questions SharePoint 2013. SharePoint 2013.disable views from user to create SharePoint 2013.Power shell SharePoint 2013.SharePoint 2010 SharePoint 2016 SharePoint Administration SharePoint Alerts and Reminders SharePoint App Configuration SharePoint Apps SharePoint Bulk upload SharePoint Calculated field SharePoint Calendar View sharepoint interview questions SharePoint online interview questions SharePoint online training SharePoint Onprem vs Online SharePoint RealTime Online Training SharePoint2010 SharePoint2013 SharePoint2016 SharePointInterview SharePointOnline SharePointOnline;Restore deleted site;SharePoint 2013 show data in datagridview in C# Simple Insert update Delete Retrieve Clear in asp.net. Site Collection Operations in SharePoint 2013 Site Collection Read-Only in SharePoint 2013 site contents Sorting & Filtering SPO SPSite Site Collection Operation parameters in SharePoint 2013 Step by step to create rdlc report in .Net Store names in text files in C# Sub site Subsite Term store management. The server was unable to save the form at this time. please try again UI New look update created by using client side object model update field values in SharePoint using powershell update items in SharePoint list using client object model update modified by field using client side object model upload zip files in blog use IsNullOrEmpty in PowerShell VirtoSoftware VirtoSofware vitrosoftware WebParts what is Document Set in SharePoint 2010 What is Filter in SharePoint Dashboard what is Limited-access user permission lock down mode feature What is Modern Team site What is Target Audience in SharePoint Who Created Site Using PowerShell Workflow in SharePoint 2013 Workflow management platform in SharePoint 2013 Workflow manager for SharePoint 2013 XSL-Template.