0

I want to create a new Lookup site column named "List Attendees" which will contain unique values for each list. so i created the new lookup at the site collection level, but i faced the following problem:-

Problem 1. is that i have to defined the "Get information from" and i need to define a source from the site collection level, and i am unable to leave the "Get information from" empty at the site collection level. while i need this lookup to be associated with a sub site list, which is not available when i define a lookup from the site collection level.

now i create a new Issue tracking list which have the lookup column, but Problem2 which i faced is that i am unable to modify the "Get information from: " source at the list level, to associated the lookup with a list that is defined inside the sub-site and not with a list that is defined inside the site collection level...

so can anyone adivce on this?, although there are some built-in lookups such as a column named "Related issue" that have its "Get information from: " empty at the site collection level, while it will have a unique value at each list level, so can anyone adivce on this please?

Thanks

1

The "Related Issue" column is different from what you can do via UI or code. To create a lookup column, you need to define the list from which the values are looked up. Since "Related Issues" is refering itself, you seem to be able to use "self" for the "List" parameter instead of the actual list.

If you want to have lookup columns to various lists, you need to create a lookup column for each occasion.

I haven't checked if you can leave it empty at site collection level and fill it afterwards using code, but it seems that's not possible.

Update: To achieve what you're trying to do using PowerShell you can use the following script.

 Add-PSSnapin Microsoft.SharePoint.PowerShell

 $rootWeb = Get-SPWeb "ROOTWEBURL"
 $subWeb = Get-SPWeb "SUBWEBURL"

 $lookupList = $subWeb.Lists.TryGetList("LOOKUPLISTNAME")

 # the last parameter defines if the lookup column is required
 $lookupFieldName = $rootWeb.Fields.AddLookup("COLUMNNAME", $lookupList.ID, $subWeb.ID, $false)

Please either paste this into PowerShell ISE or any other PowerShell instance with administrator permission. Please replace your urls, list- and columnname.

  • so you mean i need to define the "List Attendees" as a list column and not as a site column ? because if i define it as a site column then i need to define a site collection list to be associated with it , and if i do so i will not be able to modify the associated list at the list level ,,, is this correct ? – john Gu Jun 1 '15 at 14:09
  • 1
    You need to create a site lookup column for the specific list "List Attendees". When this site is located at a subsite, you still can create a site column given the listid and the webid. What I'm saying is that for each list you have in a subweb, you need to have a corresponding lookup field. – Andreas Jun 1 '15 at 14:12
  • yes this what i mean,Now for the lookup field i can not create it at the site collection level, and i need to create it at the subsite level instead. as the list that i will be associating the lookup field with, only exists inside the sub site and not inside the site collection . At the beginning i though i can create a lookup column at the site collection level, then to override it at the list or sub site level and chnage the "Get information from" accordinly, but seems the ""Get information from"" will be readonly at the list and subsite levels incase i define it at the site collection level – john Gu Jun 1 '15 at 14:20
  • 1
    Are you working with SSOM, CSOM or JSOM so that I can lookup a piece of code for you to help you out. If you're using Server Object model have a look at this link. If you have the WebId and ListId of your list in the subweb, you can add it to the root web (root in sitecollection) anyway. – Andreas Jun 1 '15 at 14:23
  • i am adding the content types, columns etc from the web interface – john Gu Jun 1 '15 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.