UpdateList SharePoint Method: Newly Created Columns Not Displayed

I worked on code . It works successfully. But the problem I am facing is:

New columns do not appear in the list (I tried using the parameter "Required" = "TRUE").

I tried with estimating the field value of both visible and invisible columns. The difference I found is this: visible columns (manually created) do not contain version values. There were columns that I create.

So, I tried to pass the null value to the value "ndVersion.Value".

But it still does not work and automatically saves the version value.

Can you help me with this?

I tried the solution given here .

But it did not work again. :(

+4
source share
4 answers

There are actually a few things that happen when adding a column to a list in a browser:

  • The field is added to the list.
  • The field is added to the list of content types.
  • The field is added to the default view.

When you add a column using code, you can change only this list, but not the type of content (which defines new / editable forms) or presentation (which defines the types of list)

var field = list.Fields[fieldName]; var ctype = list.ContentTypes[contentTypeId]; var fieldref = new SPFieldLink(field); ctype.FieldLinks.Add(fieldref); ctype.Update(); var view = list.Views[viewName]; view.ViewFields.Add(field); view.Update(); 
+2
source

Try setting the ReadOnly property to "FALSE"

0
source

I would use the object model provided using Microsoft.Sharepoint.dll, instead of using web services.

Sharepoint has problems adding new columns to a content type whose changes are not always transferred to lists. I think the Sharepoint user interface does this for you when you edit the content type, but when you do it yourself in the code, you need to make sure that your changes are moved to the lists.

There are two ways to add content type data to the list programmatically.

  • via schema.xml -> Then you should let the list inherit from your content type, but you still have a list of all the fields that you want to use from your content type.
  • via code -> Add your field to the content type, but then you need to add the content type to the list again to make sure that all fields are filled in the list
0
source

Source: https://habr.com/ru/post/1300430/


All Articles