I need a way to create an announcement within the system status on the portal

Cynthia19
Tera Contributor

Hello Developers,

 

I want to be able to create announcements on the system status on the service portal so that when go to knowledge and create a KB = IT and category = Email

Then the article will display within the announcement field on the system status page of the service portal 

4 REPLIES 4

Jan Cernocky
Tera Guru

Hi Cynthia,

which 'announcement field' are you referring to? There is no announcement widget on system status page in OOB.

My suggestion would be to create a business rule after creation (or publishing) a KB article with the parameters you specified to create an announcement record (and define it only for widget, not banner)

Additionally you would need to place Announcement widget in system status page to show that announcement.

Banner is not feasible here as it can only be limited on portal level so if you want to see it only on system status page it would still bother other portal users.

Hello @Jan Cernocky 

 

My apologies for the confusion, that is exactly what I am looking for 

How do I modify the KB article with the parameters you specified to create an announcement record (and define it only for the widget).

I found an existing widget that does exactly what I am looking for and I cloned and modified the parameters or at least I think I did but it does not seem to work. I have attached a copy of my script below. Can you have a look and let me know where I went wrong

 

And how do I place the Announcement widget in the system status page to show the announcements

 

var t = data;

var z = new GlideRecord('kb_knowledge');

z.addQuery('workflow_state', 'published');

z.addQuery('kb_knowledge_base.', 'CONTAINS', 'IT');

z.addQuery('valid_to', '>=', (new GlideDate()).getLocalDate().getValue());

z.addEncodedQuery('publishedONLast 7 days@javascript:gs.beginningOfLast7Days()@javascript:gs.endOfLast7Days()');

z.orderByDesc('published');

z.setLimit(options.max_number || 5);

z.query();

t.rowCount = z.getRowCount();

t.articles = [];

t.title = options.title || gs.getMessage("Announcement");

 

while (z.next()) {

  if (!z.canRead())

    continue;

 

  var a = {};

  a.short_description = z.getValue('short_description');

  a.sys_view_count = z.getValue('sys_view_count');

  a.sys_id = z.getValue('sys_id');

  a.published = z.getValue('published');

  a.published_display = gs.getMessage("Published {0}", z.getDisplayValue('published'));

  t.articles.push(a);

}

 

 

 

Hi Cynthia,

before you begin to setting this up - be aware that announcements cannot work with multiple lines. So if you want to publish the KB article content you may end up like this

find_real_file.png

Anyway, your script seems too complicated, my steps would be following:

1. Create after update business rule with conditions you need (knowledgebase, category, + workflow changes to Published - you only want to create announcement when KB article is being published, right?) Be aware there are two 'Category' fields in the article you need to choose the kb_category

find_real_file.png

2. Create a script in this business rule, to create a new announcement

(function executeRule(current, previous /*null when async*/) {	
	var announcementGR = new GlideRecord('announcement');
	announcementGR.initialize();	
	announcementGR.name = 'Autocreated from ' + current.number;
	announcementGR.title = current.short_description;	
	var fromDateTime = new GlideDateTime(); // adjust date according to your needs
	announcementGR.from = fromDateTime;	
	announcementGR.summary = current.text;	
	announcementGR.type = '67eaf134e7a3320075c2a117c2f6a9d2'; // sys ID of 'Widget' type		
	announcementGR.insert();	
})(current, previous);

3. Test that if you create a new article matching conditions of BR it will create a new announcement in the [announcement] table

4. Go to portal System status page, Ctrl + Right click on a widget and select 'Edit in Page editor'

5. Find Announcement widget and move it to page where you need it 

find_real_file.png

6. Test that System status page again, you should be able to see it 

 

12QSFGHCGD
Tera Contributor

Hi @Jan Cernocky 

 

It is creating a new announcement but when i am trying to update the existing kb article instead of updating the annoucement it is again creating a new announcement.