
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 05:52 PM
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();
Thanks,
Kent
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 06:37 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 06:37 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 08:19 PM
Thanks Matthew,
It is working well.
Thank you for your kindness!!
Kent