Saturday, 1 August 2015

Enable the calculated value option in SharePoint using PowerShell.

In this example we are able to show how to select the calculated value property using PowerShell, as per our requirement we have to show the X years date while creating a new item using the calculated formula we are unable to the field in NewForm.aspx, but using the Calculated value option we can show the filed in the NewForm.aspx Page.

  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 

Add-PSSnapin Microsoft.SharePoint.PowerShell
$web = Get-SPWeb "http://dotnetsharepoint.com/sites/sharepoint/enableformula"
$list = $web.lists["ListName"]
if($list.Fields.ContainsField("Date") -eq $true)
 {
      Write-Host  "Field Date already avilable in the list"
      }
 else
 {
 $list.Fields.Add("Date","Date",$false)
 $list.Fields["Date"].DisplayFormat = "DateOnly"
 $DateField = $list.Fields.GetField("Date") #Get the field
 $DateField.DefaultFormula = "=DATE(YEAR(Today)+3,MONTH(Today),DAY(Today))"
 $DateField.update();
}


Once this PowerShell is completed we can able to see the Date field Calculated Value as shown below. 

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

Friday, 31 July 2015

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

Wednesday, 29 July 2015

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

Friday, 24 July 2015

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



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

Wednesday, 22 July 2015

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

Tuesday, 21 July 2015

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
Related Posts Plugin for WordPress, Blogger...