How to create list with CustomSchemaXML?

Yuvraj Patil 441 Reputation points
2022-07-06T08:49:56.653+00:00

I have a requirement where I am taking the list schema xml and then deleting the list and need to create the list again. I am trying to get the schema xml of list before deleting and create list using the same schema xml. Could you please help me to create list using schema xml.

I am trying below code which of course it is giving error.

ListCreationInformation newList = new ListCreationInformation();  
  
newList.Title = "CustomList";  
newList.TemplateFeatureId = new Guid("00bfea71-e717-4e80-aa17-d0c71b360101");  
newList.TemplateType = 101;                  
newList.CustomSchemaXml = "<List Title='CustomList' Direction='none'></List>";  
var targetList = web.Lists.Add(newList);  
  
clientcontext.ExecuteQuery();  

Please help to create list using schema xml of earlier list.

Thanks in Advance !!!

@RaytheonXie_MSFT

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,418 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,176 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,267 questions
{count} votes

Accepted answer
  1. Tong Zhang_MSFT 9,246 Reputation points
    2022-07-07T08:20:11.733+00:00

    Hi @Yuvraj Patil ,

    According to my research and testing, we cannot create a List using the custom SchemaXML in CSOM. Here is a similar issue you can refer to : https://social.msdn.microsoft.com/Forums/Lync/en-US/4c22ced6-0bf2-485a-b0fa-0a2aea3a5a30/how-to-use-customschemaxml-to-create-list-in-csom

    Thanks for your understanding and support.

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.