Scheduled job email reminder 30/60/90

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 01:00 AM
Hi Experts,
I need to send a email reminder and create comments on a record if the user hasnt updated it after 30 days and 60 days.
How can create a comment on the record with out updating the record - I've tried gr.autoSysFields(false); but this fires the notification and does not update the record (see code below)
var gr = new GlideRecord('sn_hr_core_case');
gr.addEncodedQuery('sys_updated_onRELATIVELT@dayofweek@ago@30');
gr.addQuery('assignment_group' ,'IN',gs.getProperty('sn_hr_core.hr.assignmemt.group'));
gr.query();
while (gr.next()) {
gr.comments = 'You have not provided an update on your case within the last 30 days. It is really important that you provide an update within the next 60 days or the case will be closed.
gr.autoSysFields(false);
gr.update();
Can anyone advise?
Thanks
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 01:04 AM
Hi,
why don't you just update the comments?
why this is required -> gr.autoSysFields(false);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 01:07 AM
Hi,
Journal fields (like additional comments and work notes) are special, they exist as a separate record.
So it's not possible to write a comment or a work note without updating the record (sn_hr_core_case).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 01:13 AM
Hi,
alternative here -> create record into sys_journal_field using GlideRecord while iterating
var gr = new GlideRecord('sn_hr_core_case');
gr.addEncodedQuery('sys_updated_onRELATIVELT@dayofweek@ago@30');
gr.addQuery('assignment_group' ,'IN',gs.getProperty('sn_hr_core.hr.assignmemt.group'));
gr.query();
while (gr.next()) {
var rec = new GlideRecord('sys_journal_field');
rec.initialize();
rec.name = 'sn_hr_core_case';
rec.element_id = gr.getUniqueValue();
rec.element = 'comments';
rec.value = 'You have not provided an update on your case within the last 30 days. It is really important that you provide an update within the next 60 days or the case will be closed';
rec.insert();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2022 01:46 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader