How to choose a portal on announcement table automatically?

Kento Takahashi
Giga Contributor

 

Hi all,

 

I would like to create announcement record by using schejule job(= automatically).

Like below, I can create an announcement.

However, I cannot choose portal.

If you know the way of choosing portal, plaese let me know.

var grAnnounce = new GlideRecord('announcement');
grAnnounce.initialize();
grAnnounce.name = 'xxx';
grAnnounce.title = 'yyy';
grAnnounce.summary = 'zzz';
grAnnounce.from = '2019-02-14 00:00:00';
grAnnounce.active = 'true';
grAnnounce.insert();

find_real_file.png

 

Thanks,

Kent

1 ACCEPTED SOLUTION

Matthew Glenn
Kilo Sage

You'll need to create a record on the "m2m_announcement_portal" table and associate it with the newly created announcement. Something along the lines of:

var portal = new GlideRecord("m2m_announcement_portal");
portal.initialize();
portal.announcement = grAnnounce.sys_id;
portal.sp_portal = "81b75d3147032100ba13a5554ee4902b";  //sys_id of your portal
portal.insert();

This can be done in the same scheduled job as your announcement creation. 

 

View solution in original post

2 REPLIES 2

Matthew Glenn
Kilo Sage

You'll need to create a record on the "m2m_announcement_portal" table and associate it with the newly created announcement. Something along the lines of:

var portal = new GlideRecord("m2m_announcement_portal");
portal.initialize();
portal.announcement = grAnnounce.sys_id;
portal.sp_portal = "81b75d3147032100ba13a5554ee4902b";  //sys_id of your portal
portal.insert();

This can be done in the same scheduled job as your announcement creation. 

 

Thanks Matthew,

 

It is working well.

Thank you for your kindness!!

 

Kent