Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a following task in sharepoint 2007 to identify if the list fields come from the parent web or site col, this i'm planning to do with a powershell script.

So what I want to do is to iterate thru all the site collections, the sites (webs) and the lists on them, and in every list i want to iterate thru all the fields and see if those fields come from site col or web, or are they only defined in the list it self.

My question is: is it possible when having an SPField object to identify where it comes from? Or should i get all the fields on the web or site col and then based on this spfields find a reference in what lists they are being used, and then retrieve them to perfrom some operations?

And what is the best way to do this, because i need to compare some settings if they are same, like display name?

Thanks for the help

share|improve this question

1 Answer 1

Having an SPField there is no direct way of finding out if it has been defined in the List, ListDefinition or as a Site Column.

All fields created by the user in the UI will have the SourceId set to the ID of the list. But when you define a site column or a field in a list definition you can set that to anything.

If you "only" want to find out if the field has been define as a Site Columns at some level you can just get SPWeb.AvailableFields[SPField.ID], this will return null if not a site column and otherwise a SPField defining the Site Column regardless of which site it was created on.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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