Customer Portal

Get Involved. Join the Conversation.

Topic

    Ryan Patrosso
    FormInput on a custom field removing new lines from string
    Topic posted June 9, 2017 by Ryan PatrossoGreen Ribbon: 100+ Points 
    150 Views, 7 Comments
    Title:
    FormInput on a custom field removing new lines from string
    Content:

    I have a FormInput widget setup as shown below. However, the multiple lines of text seperated by blank lines only shows up correctly when the page loads and during data entry but when submitted the data converts to a single line of text and loses all line breaks. When I change the name field to incidents.thread it keeps all formatting but I need it to input into the custom field and when the name is a custom field the formatting disappears. I have tried inserting unicode line breaks as well as "\n" and <br /> into the blank lines but both show up in the text of the default value which is not desired plus they do not format the output anyway.

    Version:
    Oracle Service Cloud May 2016 Customer Portal 3.3 Build 232 SP 6, CP 232
    Code Snippet:

    Comment

     

    • Anuj Behl

      Hi Ryan,

      What is the data type of this custom field in database? It should be textarea to be able to store line-breaks.

      -Anuj

       

    • Ryan Patrosso

      Hey Anuj,

      The custom fields data type is a Text Area in the Configuration>Database>Custom fields area.

      Thanks,

      Ryan

    • Barrilito van Dijk

      Hi Ryan,

      Not sure about this. I do know that an incident thread is an object and will be treated different, it is converted to a string under the hood if I am correct. However, how did you test that with the thread the formatting stays and that in the custom field it does not? Did you just look in the console and opened the incident and looked in the fields there, or did you make a report to look at the real data stored in the fields?

      I don't have to much time to dive into it, but I would say, dive into the widgets code to see what the formInput widget does. In your case with a text area it will lead you to the textInput widget. So look into there what it does precisely, the clue must be seen there I guess.

      Regards

    • Ryan Patrosso

      Barrilito,

      The form is inputting data into an incident workspace. In the workspace it has formatting. I just checked a report as you suggested and it also had formatting. After it gets to the workspace, a rule is moving the text into a note in the thread, once in the thread it has no formatting which is where I originally checked it. It appears now that the rule using standard text containing the custom fields is what is removing the formatting in order to append it as a note.

      Thanks

    • Barrilito van Dijk

      Hi Ryan,

      Good to hear you tested it the way I described. So, is your question solved now?
      Regards

    • Steven Robert

      Bumping this thread as I have run into the same thing that Ryan did, namely:

      "standard text containing the custom fields is what is removing the formatting"

      When I put a field in standard text it strips the line breaks. Is there a way to persist line breaks in standard text?

      The field is populated by OPA, so if there a string that would force  line break we can substitute that in.

      • Steven Robert

        OK, now I can answer my own question!

        Html codes seem to flow from fields to standard text entries, hence <br> renders a line break in standard text.

         

        Ryan, not sure if it matters any more, but if your widget replaced line breaks with <br> before saving then they would flow through to threads.