none
how to retrive the data of multiline text using CSOM?

    Question

  • how to i get CSOM code retrieve multi line text from sharePoint online?

    When i tried to add this string richTextField = Convert.ToString(itm.FieldValuesAsText["Teammembers"]);. i got this error microsoft.sharepoint.client.propertyorfieldnotinitializedexception 

    i was able to get other fields relatively easily

          Web web = ctx.Web;
                    List list = web.Lists.GetById(new Guid("fe15d182-4e65-48a9-a613-6dcfae756c69"));
                    var q = new CamlQuery() { ViewXml = "<View><Query><Where><Eq><FieldRef Name='Manager' /><Value Type='User'>TOM</Value></Eq></Where></Query></View>" };
                    var r = list.GetItems(q);
                    ctx.Load(r);
    
    
                    string result = string.Empty;
                    foreach (SPclient.ListItem itm in r)
                    {
                        FieldUserValue name = itm.FieldValues["Manager"] as FieldUserValue;
                        string person = name.LookupValue;
                        //Console.WriteLine(itm.Id + "     " + itm["Manager"].ToString() + "     " + person);
    
                        MessageBox.Show(itm.Id + "     " + itm["Title"].ToString() + "     " + multitextValue + "    " + person);
                    }


    • Edited by roma_victa Monday, February 27, 2017 9:42 AM
    Monday, February 27, 2017 9:33 AM

Answers

  • static void Main(string[] args)
            {
                string siteUrl = "http://yoursiteUrl";
    
                ClientContext clientContext = new ClientContext(siteUrl);
                var web = clientContext.Web;
                var list = web.Lists.GetByTitle("MyList");
    
                var listFields = list.Fields;
    
                clientContext.Load(listFields);
    
                var itemId = "1";
                var listItem = list.GetItemById(itemId);
                var itemFieldValues = listItem.FieldValuesAsText;
    
                clientContext.Load(itemFieldValues);
                clientContext.ExecuteQuery();
    
                string multitextValue = itemFieldValues["MyMultiLineTextField"];
                
            }
    I got the reply from here

    Avijit Sur

    • Marked as answer by roma_victa Monday, February 27, 2017 10:47 AM
    Monday, February 27, 2017 9:42 AM