0

I can provide the ViewFields but I was wondering if there is a way to return all the user created fields (non-hidden ones) without having to do that.

I know this works:

<ViewFields>
    <FieldRef Name="UserCreatedField1" />
    <FieldRef Name="UserCreatedField2" />
    <FieldRef Name="UserCreatedField..." />
    <FieldRef Name="UserCreatedFieldX" />
</ViewFields>

But I'm hoping there is an easier way then specifying each FieldRef.

2 Answers 2

0

You need to explicitly request for each fields you want.

5
  • I'm using an extension method which generates the FieldRefs for me for a given FieldName Collection.
    – Andreas
    Commented Jun 1, 2015 at 13:51
  • @Andreas Yes using custom code we can find out user fields. But I believe IMTheNachoMan is look for attribute which can provide this functionality out of the box. Commented Jun 1, 2015 at 13:55
  • @AmalHashim Do you have a link for me to identify user fields using code?
    – Andreas
    Commented Jun 1, 2015 at 14:01
  • 1
    Yes. SPField has a property FromBaseType. If the value of that field TRUE means it is created by user. Commented Jun 1, 2015 at 14:04
  • I just tried it and it seems to work only for fields created using the ui. Do you know an other property which seperates system fields from later added fields (either ui or programmatically).
    – Andreas
    Commented Jun 1, 2015 at 14:21
-1

You may first connect to list programmatically and get all feilds as collection then look for non hidden fields and you get non hidden fields collection. Then write your own caml query with collection.

1
  • I wanted to avoid first collecting a list of user created fields. For example, I can't programmatically change a DVWP SelectCommand but I don't want to have to edit it every time I add a new field. Commented Jun 1, 2015 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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