Announcement widget on service portal, Summary of announcement is not shown until expanded.

Servicenow Stud
Mega Contributor

Hi All,

I have created a new Announcement and entered summary into it. But the complete announcement is not shown until it is expanded. How to make the complete announcement visible on load itself.

find_real_file.png

find_real_file.png

Thanks

1 ACCEPTED SOLUTION

Yes you can , you have to dig into the widget client script.

 

 

Clone the "Announcements" widget and set a.expanded = true;  in client controller script. 

 

find_real_file.png 

 

If my answer helped you, kindly mark it as correct and helpful.

View solution in original post

9 REPLIES 9

So in that case you can try to create your own widget.

 

You will need to do the glide record on announcement table and get summary of active announcement record and show it over widget html script. 

 

Sample code: for further styling modification, you can add css . 

 

HTML:

 

<div class="details" >
    <table>
      <tr ng-repeat="announce in data.announcement">

        
        <td>
           <ul>
              
          <li>{{announce.summary}}</li>
        
        </ul>
        </td>
          

      </tr>
    </table>
  </div>

 

 

Server Side Script:

 

(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.announcement = [];


var gr = new GlideRecord('announcement');
gr.addQuery('active',true);
gr.query();
while(gr.next()){

var announce = {};
announce.summary = gr.getDisplayValue('summary');
data.announcement.push(announce);
}

})();

 

If you want to apply CSS , kindly check the link and apply the css based on your need. 

 

https://www.w3schools.com/css/default.asp

Hi @Harshvardhan ,

Instead of creating new Widget, is there any chance to modify lines in cloned widget, just to make announcement widget always expandable?

Thanks

Yes you can , you have to dig into the widget client script.

 

 

Clone the "Announcements" widget and set a.expanded = true;  in client controller script. 

 

find_real_file.png 

 

If my answer helped you, kindly mark it as correct and helpful.

Thank you @Harshvardhan , it worked great.

Harsh Vardhan
Giga Patron

Let me know if you need any further help.

If my answer helped you, kindly mark my answer as correct and close this thread,  so that others can benefit from similar question in future.