Below script will helps us on how to create single line of text and multi line of text fields in SharePoint using PowerShell. please refer my previous posts on below scenarios:
Download URL: Click here to download script
In SharePoint, we can create multi line of text fields with 3 types of attributes[see below image]
Below PowerShell scripts will works on SharePoint 2013/2010/2007
Thanks,
Sasi Kumar Reddy
- Create a new list in SharePoint using powershell?
- Check whether the list exits or not?
- Create a new field in SharePoint list using powershell
- Add items to the list in SharePoint using powershell?
Download URL: Click here to download script
In SharePoint, we can create multi line of text fields with 3 types of attributes[see below image]
Below PowerShell scripts will works on SharePoint 2013/2010/2007
=================================================================================== $listname="ListName" =================================================================================== $docSite = new-object Microsoft.SharePoint.SPSite($siteURL) $docWeb = $docSite.OpenWeb() =================================================================================== function Add-SPMutliLineoftextField([string]$listName, [string]$DisplayName, [string]$Name, [string]$Required, [string]$NumLines, [string]$RichText, [string]$RichTextMode) { $OpenList = $docWeb.Lists[$listName] $multiLineCol1 = "Please let me know if faced any issues while using the above scripts and provide your valuable feedback." $OpenList.Fields.AddFieldAsXml($multiLineCol1,$true, [Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView) } function Add-SPSingleLineOfTextField([string]$listName, [string]$DisplayName, [string]$Name, [string]$Required, [string]$DateType) { $OpenList = $docWeb.Lists[$listName] $firstNameColXml = " " $OpenList.Fields.AddFieldAsXml($firstNameColXml,$true, [Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView) } ==================================================================================== Write-Host "`n Adding fields to the $listname list `n" //To create a single line of text field Add-SPSingleLineOfTextField -listName $listname -Name singlelineoftextfieldName -DisplayName singlelineoftextfieldName -Required FALSE //To create a multiline of rich text field Add-SPMutliLineoftextField -listName $listname -Name mutliLineoftextFieldName -DisplayName mutliLineoftextFieldName -Required TRUE -NumLines 8 -RichTextMode Compatible -RichText TRUE //To create a multiline of enhanced rich text field Add-SPMutliLineoftextField -listName $listname -Name mutliLineoftextFieldName -DisplayName mutliLineoftextFieldName -Required TRUE -NumLines 8 -RichTextMode FullHtml -RichText TRUE //To create a multiline of plain text field Add-SPMutliLineoftextField -listName $listname -Name mutliLineoftextFieldName -DisplayName mutliLineoftextFieldName -Required TRUE -NumLines 8 -RichTextMode FullHtml -RichText FALSE ====================================================================================
Thanks,
Sasi Kumar Reddy
No comments:
Post a Comment