Are some properties missing from SPFieldLink?
When you try to construct data relationship structure in SharePoint, at some point you might notice that
SPFieldLink is missing the two boolean flags known from
ShowInNewForm. To make it more confusing, the
ShowInDisplayForm flag is available and exposed as a public property.
Should the missing properties be available? That’s clearly what developers expect. Moreover, MSDN documentation displays those properties in example on the SPFieldLink.SchemaXML documentation page. Also,
SPField object contains private fields for
ShowInNewForm. Is it just a mistake that those fields weren’t exposed as public properties, or the functionality is just not implemented in SharePoint 2013?
This article presents a little SharePoint weirdness that you might encounter when you try to add the column of the
Integer to the site columns collection.
The following line seems perfectly fine in Visual Studio, the code compiles and throws no exception at runtime:
web.Fields.Add("myField1", SPFieldType.Integer, false);
Creating most types of lists (or apps in SharePoint 2013 terminology) in C# code is pretty straightforward. You just need to choose the correct list type from the built-in enum
Microsoft.Sharepoint.SPListTemplateType. Then, you can create list by invoking appropriate
Add() method on a
SPListCollection, like in the first example:
private SPList AddList(SPWeb web, SPListTemplateType templateType,
string internalName, string displayName, string description)
// add list
Guid listGuid = web.Lists.Add(internalName, description, templateType);
// now you can modify list properties, add content types, fields etc.
SPList listObj = web.Lists[listGuid];
listObj.Title = displayName;