Advertisement
Continution to Previous post , here we are going to see how to create lookup field from Power Shell in SharePoint 2013
Create a SharePoint Custom List Department with Lookup Column
SNAME - Lookup
SID -Number
#List type or template
$spTemplate = $spWeb.ListTemplates["Custom List"]
#Get all the lists to the listcollection
$spListCollection=$spWeb.Lists
#adding the new list to the list collection
$spListCollection.Add("Department","Department",$spTemplate)
#get the path of subsite and sitecollecion
$path = $spWeb.url.trim()
#get the list to the list object
$spList = $spWeb.GetList("$path/Lists/Department")
#adding the field type(Lookup) to the list
$LookupList= $spWeb.Lists["Student"]
$fieldXml='<Field Type="Lookup" DisplayName="SName" ShowField="SName" StaticName="SName" List="' + $LookupList.id + '" Name="SName"></Field>'
$spList.Fields.AddFieldAsXml($fieldXml,$true,[Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView)
#adding the field type(Number) to the list
$spFieldType = [Microsoft.SharePoint.SPFieldType]::Number
$spList.Fields.Add("SID",$spFieldType,$false)
$Views = $spList.Views["All Items"]
$Views.ViewFields.Add("SID")
$Views.Update()
Create a SharePoint Custom List Department with Lookup Column
SNAME - Lookup
SID -Number
#List type or template
$spTemplate = $spWeb.ListTemplates["Custom List"]
#Get all the lists to the listcollection
$spListCollection=$spWeb.Lists
#adding the new list to the list collection
$spListCollection.Add("Department","Department",$spTemplate)
#get the path of subsite and sitecollecion
$path = $spWeb.url.trim()
#get the list to the list object
$spList = $spWeb.GetList("$path/Lists/Department")
#adding the field type(Lookup) to the list
$LookupList= $spWeb.Lists["Student"]
$fieldXml='<Field Type="Lookup" DisplayName="SName" ShowField="SName" StaticName="SName" List="' + $LookupList.id + '" Name="SName"></Field>'
$spList.Fields.AddFieldAsXml($fieldXml,$true,[Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView)
#adding the field type(Number) to the list
$spFieldType = [Microsoft.SharePoint.SPFieldType]::Number
$spList.Fields.Add("SID",$spFieldType,$false)
$Views = $spList.Views["All Items"]
$Views.ViewFields.Add("SID")
$Views.Update()
How create multiple lookup column?
ReplyDeleteChange Field Type to "LookupMulti"
ReplyDeleteand add Mult="TRUE"
Delete04EFE212DF
ReplyDeletemmorpg oyunlar
whatsapp sms onay
mobil ödeme bozdurma
en güvenilir takipçi satın alma sitesi hangisi
bayan takipçi
442FD1505F
ReplyDeletekiralık hacker
hacker arıyorum
belek
kadriye
serik
689FFD833D
ReplyDeleteTakipçi Satın Al
M3u Listesi
Sıra Bulucu
Osm Promosyon Kodu
Brawl Stars Elmas Kodu