Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How can i find custom fields in a document library?

$
0
0

Hi, guys.

I need your help, please.

My users sometimes creates custom columns i document libraries using the SharePoint GUI. That's fine, but I need to distinguish these columns from SharePoints own columns. So here's my task at hand:

I need to find all the fields (columns) for a document in a document library that were added by a user, i.e. NOT SharePoint standard fields. Is there a way to do this, like a property or something?

In my case, I have an event receiver triggering on ItemUpdated. The following snippet iterates through all fields of my item and I can read the item title and the item value.

How can I filter this to only show title and value of custom fields?

foreach (SPField field in properties.ListItem.Fields)
{
    string title = field.Title;
    string value = string.Empty;
    if (properties.ListItem[field.Title] != null)
    {
        value = properties.ListItem[field.Title].ToString();
    }

    // Do something with 'title' and 'value'
}

Again, the code above gives me ALL columns and I only want columns created by users. If it's possible, I'd like to skip custom content type fields.


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>