Forum Discussion
Sayan DuttaMajumdar
May 17, 2017Copper Contributor
Adding Version column in SP View
Hello All-
I am adding a column in custom view. Working fine, but while checking if this column exist in the view
getting unusual issue. There is no error but simply this code is not working. Debugger is not going inside if statement always going else and adding one more version column.
Code:
View customtview;
customtview = subjectSiteDocumentsLibrary.GetViewByName("All Documents");
subjectSiteContext.Load(customtview, v => v.ViewFields);
subjectSiteContext.ExecuteQueryRetry();
if (customtview.ViewFields.Contains("Version"))
{
}
else
{
customtview.ViewFields.Add("Version");
}
customtview.Update();
subjectSiteContext.ExecuteQuery();
Any help?
Sayan.
2 Replies
Have you tried this solution:
- Sayan DuttaMajumdarCopper Contributor
Thanks Pieter , it is working through internal names.