3 Replies · Latest reply on Jun 22, 2017 10:24 AM by Geoff Luk

    How to retrieve formatted Description for ticket conversation widget?

      We're currently trying to modify the Ticket Conversations widget so that we are able to display the record's Description above the actual Conversation view. We've cloned the widget and in the Server Script we're using the basic data.object retrieval with "data.description = gr.getDisplayValue("description");", and we drop the data.description into the HTML with "{{data.description}}". It is being retrieved successfully, but unfortunately without any formatting.

       

      For example, if an Incident's Description were as follows:

      "Hi,

       

      I need help setting up my email account in Outlook.

       

      Thanks,

      John Doe"

       

      it would end up in the HTML as "Hi, I need help setting up my email account in Outlook. Thanks, John Doe" without any of the linespacing. It appears that during retrieval the gs.getDisplayValue() is stripping out line breaks. Is there a better call to get the Description field without losing the formatting?

       

      Thanks

        • Re: How to retrieve formatted Description for ticket conversation widget?
          Geoff Luk

          So to answer my own question, it turns out that the Description contents will be formatted depending on where you drop it into the Ticket Conversation widget.

           

          Previously we tried to put the Description into the upper area of the <div class="panel-body"> section, above the activity stream. This caused the unformatted Description. Instead, by mimicking the HI ticket format, we tried placing it directly into the  activity stream. Simply encapsulating the Description within the necessary Bootstrap and custom timeline-* classes for Service Portal, the Description text was automatically formatted with line spacing, etc.

           

          So what we did was add this HTML into the widget, right above the "(Ticket number) created" div:

          <li class="timeline-item timeline-inverted">
            <div class="timeline-badge">
            <sn-avatar primary="data.stream.user_sys_id" class="avatar-large" show-presence="false" enable-context-menu="false"></sn-avatar>
            </div>
            <div class="timeline-panel timeline-panel-first-item">
            <div class="timeline-heading">
            <h4 class="timeline-title">{{data.stream.user_full_name}}</h4>
            <p>
            <small class="text-muted">
            <span class="glyphicon glyphicon-time " />
            <sn-time-ago timestamp="data.created_on" />
            </small>
            </p>
            </div>
            <div class="timeline-body">
            <p><strong>Description:</strong><br /> {{data.description}}
            </p>
            </div>
            </div>
          </li>
          

           

           

          And then in the server-side code we have a simple getter:

          data.description = gr.getDisplayValue("description");
          
          • Re: How to retrieve formatted Description for ticket conversation widget?
            Chirag Bagdai

            Hi Geoff,

             

            You need to pass the description field data as HTML formatted text. Please find below example which can help you :

             

            HTML

              <div ng-if="c.description" ng-bind-html="c.description"></div>
            

             

            Client Controller :

            function ($scope, $sce) {
              var c = this;
              c.description = $sce.trustAsHtml("<h1>Hellow World!!</h1>");
            }
            

            - include $sce in function parameter.

            Hit correct/helpful based on impact.

              • Re: How to retrieve formatted Description for ticket conversation widget?
                Geoff Luk

                Hi Chirag,

                 

                Thanks for the reply. Unfortunately, our Descriptions are in plain text which means that there is essentially no formatting except for line breaks. I failed to mention that we're using Plain Text in my original post.

                 

                However, as I mentioned in my followup post we have the Description displaying correctly, with formatted line breaks, in the Ticket Conversation widget. This is actually preferable for us, as it mimics the way that HI tickets appear in the SNOW SP.