In this article we are going to learn “how to get the sharepoint internal field name using the display name” of field.
To perform any operation on the field. First we need to get field collections, every SharePoint list have fields and we can get it as FieldCollection. By iterating the field collection we can get information about all the fields.
Call the method and pass the context , name of the list from which you want to get data and display name.
GetInternalFieldName( ClientContext clientContext ,string listName, string fieldDisplayName){
string fieldInternalName= " ";
var web = clientContext.Web;
clientContext.Load(web);
List listEventSource = web.Lists.GetByTitle(listName);
FieldCollection fields = listEventSource.Fields;
IEnumerable<Field> fieldsColl = clientContext.LoadQuery(fields);
clientContext.ExecuteQuery();
foreach (Field f in fieldsColl)
{
if (f.Title ==fieldDisplayName)
{
fieldInternalName = f.InternalName;
break;
}
}
}
Comments
Post a Comment