none
Retrieving value of multiple line column using CSOM RRS feed

  • Question

  • Hi

    I am retrieving value of a multiple line column on a page in a <p></p> tag but i am not getting the exact format ,

    please see the below image for reference and help

    Thanks in advance

     


    Paru

    Sunday, January 8, 2017 6:31 PM

Answers

  • Hi Lee

    Thank you for your response, issue was that the text which was retrieved had \r\n in between

    for example : '. \r\nThe SAB is responsible for:\r\n\r\n1. Prioritising and managing the system budget \r\n2.

    I could resolve it using the replace regex

    str =listItem.get_item('Content');
    tabContent = str.replace(/(?:\r\n|\r|\n)/g, '<br />');

    Thanks for help

    Paru


    Paru

    Thursday, January 19, 2017 6:59 PM

All replies

  • Hi,

    I tried to test in my local but seems not reproduced your issue, you could check below test code.
    Could you provide more details for your solution if this doesn’t help.

    Best Regards,
    Lee

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

    Monday, January 9, 2017 8:11 AM
  • Hi Lee                               

    Thanks for the reply, below is my code which i am using to get text from a list on a page in html, but for multiple line line column i am not getting the exact format i.e. the spaces and the bullet points in next line etc.

    /////////////////////////////////////////////////////////////////

    function onSucceededTab(sender, args) {
           
           var enumerator = tabDetailColl.getEnumerator();  

           var markupTab = 'List is not found<br><br>';   

             var tabName=' ';


          while (enumerator.moveNext()) {   
          var listItem = enumerator.get_current();   

         tabName =listItem.get_item('Title');
         tabContent =listItem.get_item('Content');
    tabLinkText =listItem.get_item('LinkText');
    tabHyperlink = listItem.get_item('Hyperlink').get_url();

       tabImage = listItem.get_item('Image').get_url();

         }   

              document.getElementById('tabFirst').href = '#' + tabName;
      document.getElementById('tabFirst').innerHTML = tabName;
      document.getElementById('tab1').innerHTML = tabContent;
    document.getElementById('hyperlink1').innerHTML = tabLinkText; 
    document.getElementById('hyperlink1').href = tabHyperlink; 
      document.getElementById('image1').src = tabImage;

    ////////////////////////////////////////////////////////////////////////////////////////////////


    Paru

    Monday, January 9, 2017 12:13 PM
  • Hi,

     

    I tested with below code and the value contains P/UL etc.. you could try with the code.

     

    <script>
    ExecuteOrDelayUntilScriptLoaded(LoadItems, "sp.js");
            function LoadItems() {
                var ctx = new SP.ClientContext.get_current();
                var list = ctx.get_web().get_lists().getByTitle("My-List");
                var caml = SP.CamlQuery.createAllItemsQuery();            
                this.items = list.getItems(caml);
                ctx.load(this.items);
                ctx.executeQueryAsync(Function.createDelegate(this, this.onSucceededCallback), Function.createDelegate(this, this.onFailedCallback));
            }
    
            function onSucceededCallback(sender, args) {
                var libList = "";
                var ListEnumerator = this.items.getEnumerator();
    
                while (ListEnumerator.moveNext()) {
                    var currentItem = ListEnumerator.get_current();
                    comment = currentItem.get_item('Comment');
    document.getElementById('tab1').innerHTML = comment;
                    //alert(comment);
                }            
            }
    
            function onFailedCallback(sender, args) {
                alert("failed. Message:" + args.get_message());
    
            }
        </script><div id="tab1"></div>

    Best Regards,

    Lee


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

    Tuesday, January 10, 2017 2:02 AM
  • Hi Lee

    I wrote the same code just the difference was i had P tag in my HTML instead of DIV, now having changed it still it  is not the same format.

    Why is it coming in just one paragraph? not new lines no proper spaces.

    Please help as client requires the data to come in exact forma as we are entering in the column.

    Shall i use some other column type?

    Thanks

    Paru


    Paru

    Tuesday, January 10, 2017 1:06 PM
  • Hi,

     

    I also tested with Multiple lines of text, what’s the container you used to insert the value of Multiple lines of text?(I’m using div as you see)

     

    Best Regards,

    Lee


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

    Wednesday, January 11, 2017 1:37 AM
  • Hi,

    Is any update for your issue?

    Best Regards,

    Lee


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

    Monday, January 16, 2017 10:12 AM
  • Hi Lee

    Thank you for your response, issue was that the text which was retrieved had \r\n in between

    for example : '. \r\nThe SAB is responsible for:\r\n\r\n1. Prioritising and managing the system budget \r\n2.

    I could resolve it using the replace regex

    str =listItem.get_item('Content');
    tabContent = str.replace(/(?:\r\n|\r|\n)/g, '<br />');

    Thanks for help

    Paru


    Paru

    Thursday, January 19, 2017 6:59 PM