3

I am working on sharepoint server 2013. now i have the following column named "Date Reported", which have the following properties:-

  • Display-Name = Date Reported
  • Internal Name = Date_x0020_Reported

enter image description here

now i wrote the following code inside my console APP :-

 foreach (SPListItem item in testList.Items)
                            {

                                var test1 = item["Date_x0020_Reported"];
                                var test2 = item["Date Reported"];

and seems both variables Test1 & Test2 got the correct date value. which means i can reference the item field value either using the field display name Or the field internal name? is this the case? and if the answer is Yes then could this cause conflicts .. let say a field internal name equal another field display name ?

Thanks

1

From MSDN: https://msdn.microsoft.com/library/microsoft.sharepoint.splistitem

For an indexer based on a name, Microsoft SharePoint Foundation first looks for the field by internal name and then by display name.

Conclusion:

There was no conflict, except that in the same query you're using a mixture of internal names and display names.

In general it is always advisable to use internal names.

1

Hi Prefer using internal name while query because when change the column name to something else then the query won't work by using display name.

Try querying record by changing the column display name to something else.

  • but what will sharepoint expect Internal name or Display name ? or will accept both ? – john Gu Oct 24 '16 at 0:55
  • It is advised to go with Internal name because you never who or when somebody has changed the Dispay Name of the given column. – Sunil Sahu Oct 24 '16 at 6:08
  • i know it is better to use internal but my question is about how SP works will it looj for internal names or for display names? – john Gu Oct 24 '16 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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