Just a quick interesting remark on SharePoint CSOM.
I was trying to batch upload a bunch of records in a list that contains an "Email" field. My code consisted of a loop and the creation of items using ListItemCreationInformation and setting the fields on the added item like this:
The operation fails with the following exception message
Column 'Email' does not exist. It may have been deleted by another user. /sites/MySite123/Lists/MyList123
So I used CSOM itself to explore the issue further by getting some information on the field. Then checking the internal name using
I got the unexpected value of "_x0065_zz0" but I was not surprised because there is a lot of "anomalies" to deal with when using SharePoint. I am still not sure why the internal name is like this. I have a feeling that the user who created the columns created strange names for them, and then renamed the fields. Renaming a SharePoint field does not change its Internal Name that you use with ParseAndSetFieldValue and other CSOM interfaces.
To find the internal name, I use CSOM to get a field from a field collection by using its title as follows:
My field name is "Mobile No." so this returns "Mobile_x0020_No_x002e_". The internal names do not contain special characters such as the space, the comma, or the period so they are hex encoded.
I was trying to batch upload a bunch of records in a list that contains an "Email" field. My code consisted of a loop and the creation of items using ListItemCreationInformation and setting the fields on the added item like this:
item.ParseAndSetFieldValue("Email", email);
//other fields omitted.
The operation fails with the following exception message
Column 'Email' does not exist. It may have been deleted by another user. /sites/MySite123/Lists/MyList123
So I used CSOM itself to explore the issue further by getting some information on the field. Then checking the internal name using
var internalName = list.Fields.GetByTitle("Email").LoadExec().InternalName;
I got the unexpected value of "_x0065_zz0" but I was not surprised because there is a lot of "anomalies" to deal with when using SharePoint. I am still not sure why the internal name is like this. I have a feeling that the user who created the columns created strange names for them, and then renamed the fields. Renaming a SharePoint field does not change its Internal Name that you use with ParseAndSetFieldValue and other CSOM interfaces.
To find the internal name, I use CSOM to get a field from a field collection by using its title as follows:
list.Fields.GetByTitle("Mobile No.").LoadExec().InternalName
My field name is "Mobile No." so this returns "Mobile_x0020_No_x002e_". The internal names do not contain special characters such as the space, the comma, or the period so they are hex encoded.