- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2022 07:44 PM
I would like to prepare two announcement widgets on the service portal and divide the contents to be displayed according to the contents.
For example, create a category field in the announcements table.
Use this category field to separate announcements.
Create the following widget on the service portal.
(Widget that duplicates the announcements widget)
・Operational status
・News
I want the "Operation Status" widget to display only the records whose category is Operation Status, and the "News" widget to display only the records whose category is News.
By modifying the Body HTML template and Server script, we were able to separate the widgets into categories.
I just want it to look like the default announcement widget.
※ The summary will be displayed when you click it, etc.
How do I fix the widget?
Below is the content of the modified widget.
â–¼Body HTML template
<div ng-class="['panel', 'panel-{{::c.options.color}}', 'b', 'spw-announcements-root', '{{::c.wid}}', {'accessibility-off': c.accessibilityOff}]">
<div class="panel-heading">
<h3 class="h4 panel-title"><span ng-if="c.options.glyph"><fa name="{{::c.options.glyph}}"/></span>{{::c.options.title}}</h3>
</div>
<div class="list-group">
<a class="list-group-item" ng-repeat="note in data.notes">
<h4 class="list-group-item-heading">
{{note.title}}
</h4>
<p class="list-group-item-text">
{{note.note}}
</p>
</a>
</div>
â–¼Server script
(function() {
options.title = gs.getMessage('{0}', options.title || 'Announcements');
options.max_records = options.max_records ? options.max_records : 20;
options.paginate = options.paginate === 'true' && options.max_records;
options.use_display_style = options.use_display_style === 'true';
data.rowsMessage = gs.getMessage('Rows {0} - {1} of {2}');
if (options.view_all_page) {
var gr = new GlideRecord('sp_page');
gr.get(options.view_all_page);
options.view_all_page = gr.getValue('id');
}
if (options.type) {
var types = [];
options.type.split(',').forEach(function(type) {
var gr = new GlideRecord('announcement_consumer_type');
gr.get(type);
types.push(gr.getDisplayValue('name'));
});
options.type = types.join(',');
}
data.notes = [];
var annGR = new GlideRecord('announcement');
annGR.addQuery('u_category', 'news');
annGR.addQuery('active',true);
annGR.orderByDesc('sys_created_on');
annGR.query();
while (annGR.next()) {
var annObj = {};
//use service portal helper method to get some display values
$sp.getRecordDisplayValues(annObj, annGR, 'number,title,sys_id');
//get the first 20 characters of the description
annObj.note = annGR.getValue('summary');
//push the populated obj into the array
data.notes.push(annObj);
}
})();
Solved! Go to Solution.
- Labels:
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 01:15 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2022 01:15 AM