Adding Version column in SP View

Highlighted
Occasional Contributor

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
Highlighted

Thanks Pieter , it is working through internal names.