none
SharePoint Fields from List Template using CSOM SharePoint Online RRS feed

Answers

  • Hi Suhail,

    In SharePoint Online CSOM listTemplate class, there is no property or method to get all fields which is in a list template.

    We can only get the matadata of the template like template name and desciption like below:

                ClientContext cc = new ClientContext("your online site url");
                SecureString pass = new SecureString();
    
                foreach (char c in "your password".ToCharArray())
                    pass.AppendChar(c);
    
                cc.Credentials = new SharePointOnlineCredentials("your user login name", pass);
                cc.Load(cc.Web);
                cc.ExecuteQuery();
                cc.Load(cc.Web.ListTemplates);
                cc.ExecuteQuery();
                ListTemplate template = cc.Web.ListTemplates[1];
                cc.Load(template);
                cc.ExecuteQuery();
                Console.WriteLine(template.Name);
                Console.WriteLine(template.Description);

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, October 26, 2016 7:04 AM

All replies

  • Hi Suhail,

    Can you please check the below links that give the information to retrieve all the fields using CSOM?

    https://msdn.microsoft.com/en-us/library/office/fp179912.aspx

    http://www.c-sharpcorner.com/blogs/caml-query-to-retrieve-the-items-from-a-list-using-csom1

    Sample Code:

    // Starting with ClientContext, the constructor requires a URL to the 
    // server running SharePoint. 
    ClientContext context = new ClientContext("http://SiteUrl"); 

    // The SharePoint web at the URL.
    Web web = context.Web; 

    // Retrieve all lists from the server. 
    context.Load(web.Lists, 
                 lists => lists.Include(list => list.Title, // For each list, retrieve Title and Id. 
                                        list => list.Id)); 

    // Execute query. 
    context.ExecuteQuery(); 

    // Enumerate the web.Lists. 
    foreach (List list in web.Lists) 

        label1.Text = label1.Text + ", " + list.Title; 

    Hope this answers your question.

    Thanks

    Kailas

    --------------------------------------------------------

    Please Vote or Mark as answer

    Tuesday, October 25, 2016 6:48 AM
  • Hi Kailas,

    Thanks for the suggestion; To be more specify I need to retrieve the fields from SharePoint Lists Definition / Lists Template and NOT from List Instance.

    Any idea?


    http://jsuhail.blogspot.com
    http://twitter.com/jsuhail
    http://www.linkedin.com/in/jsuhail

    Tuesday, October 25, 2016 9:49 AM
  • Hi Suhail,

    In SharePoint Online CSOM listTemplate class, there is no property or method to get all fields which is in a list template.

    We can only get the matadata of the template like template name and desciption like below:

                ClientContext cc = new ClientContext("your online site url");
                SecureString pass = new SecureString();
    
                foreach (char c in "your password".ToCharArray())
                    pass.AppendChar(c);
    
                cc.Credentials = new SharePointOnlineCredentials("your user login name", pass);
                cc.Load(cc.Web);
                cc.ExecuteQuery();
                cc.Load(cc.Web.ListTemplates);
                cc.ExecuteQuery();
                ListTemplate template = cc.Web.ListTemplates[1];
                cc.Load(template);
                cc.ExecuteQuery();
                Console.WriteLine(template.Name);
                Console.WriteLine(template.Description);

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, October 26, 2016 7:04 AM