is it possible to add multiple fields at one go in SharePoint CSOM?

I tried

List list = context.Web.Lists.GetByTitle(listname);

            string fieldSchema = "<Field Type='Text' DisplayName='NewField' Name='NewField' /><Field Type='Note' DisplayName='NewNote' Name='NewNote' />";
            FieldCollection collField = list.Fields;
            collField.AddFieldAsXml(fieldSchema, true, AddFieldOptions.AddToDefaultContentType);

It didn't work


Specifying in 1 single schema won't work. You can write as many schemas and AddFieldAsXml as you want one after the other for the number of columns you want to enter. When you execute the query after all the "AddFieldAsXml", it is executed as ONE CALL only.

Refer this: https://social.msdn.microsoft.com/Forums/office/en-US/e9fde685-b35c-466c-8898-7b87707006d2/add-multiple-columns-to-a-library-online-sharepoint?forum=sharepointdevelopment

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.