Hi All,
If you are thinking about creating a SharePoint environment with the help of our friend PowerShell, you will discover that almost everything is possible.
So let's create a 'User' (person/group) column :
### Add custom site column ###
$fieldXML = '
Description="name it"
Type=”User”
DisplayName="Add me to your list ..."
Group="Custom Columns"
Required="true"
ShowInDisplayForm="true"
ShowInEditForm="true"
ShowInListSettings="true"
ShowInNewForm="true"
List="UserInfo"
ShowField="ImnName"
UserSelectionMode = "PeopleOnly"
UserSelectionScope = "0">
$spWeb.Fields.AddFieldAsXml($fieldXML)
$spWeb.Update()
The column will appear in the 'Custom Columns'
Next thing, we will add this column to a content type :
### Add column to CT ###
$spColumn = New-Object Microsoft.SharePoint.SPFieldLink ($spWeb.Fields["Name"])
$Ct = $spWeb.ContentTypes["ContentType"]
$Ct.FieldLinks.Add($spColumn)
$Ct.Update()
Your site column was added to your content type ...
Enjoy PowerShell :-)
1 opmerking:
Your Post is very interesting and Your creation is more useeful and helpful. I like better this post than other sharepoint development post. Thanks for sharing this valuable post.
Een reactie posten