Harish Khawath

Harish Khawath

  • NA
  • 57
  • 9.2k

Get site column in new form Programmatically C#

Aug 16 2016 8:15 AM
How to get site column of share point list in new form aspx  Programmatically using C#?
 I'm trying to write script (in C#, using Server Object Model) which gets all lists (lists are as-is, no alternation is allowed) from SPWeb (SharePoint 2013) and fill them up with random information so I can stress test the site.

Anyway, I want to get fields which are displayed in (random) list's New Form. I tried exposing fields with SPField.ShowInNewForm property, but without luck (as far as I can tell, if I don't explicitly write in list's schema this property, it will return false, even if view is using this field in New Form). My second approach was to get all views tied to particular list, but I couldn't know which one of them is actually used in New Form.

Any help or tip is more then welcome.

EDIT: At the moment script is checking if SPField is required, but it's not really the solution I'm looking for (I'd like to get all fields present in New Form).

EDIT 2: Script should work even if Edit Form and New Form have different views (e.g. Title of item is shown in New Form view but not in Edit Form view).

 

Answers (1)