In SharePoint Server side code, you can write something like:
field.fieldvalueType
Which will sometimes give you the type (DateTime, or whatever). Annoyingly, sometimes, it just returns Null (for example, the ID field).
In CSOM, you don't have that field. However, there's TypeAsString
which gives SharePoint types such as:
- Computed
- Integer
- Note
What I'd like to do is grab this huge table from MSDN:
And Extract "Int32" when I know that I'm dealing with an "Integer" field, and extract "System.String" from SharePoint's note.
This kinda works, but it's the mother of all hacks:
var myTempItem = list.AddItem(new ListItemCreationInformation());
myTempItem.Update();
context.ExecuteQuery();
context.Load(myTempItem);
context.ExecuteQuery();
After creation, you can use:
myTempItemCreated[fieldImTryingToGetTypeOf.Title].GetType().FullName
-> Gives-> System.Int32
Now, what's the proper way to do it? I'm just hoping the answer isn't a ten foot long switch case statement.