Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Update worknotes with setWorkflow false

sukran
Mega Sage

How to update worknotes comments in the RITM activity, when we use setworkflow (false) through background script?

 


req.work_notes = 'closed your request with approval';
req.request_state = 'closed_complete';

req.setWorkflow(false);// will not trigger BR/Email notification
req.update();

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@sukran 

when you use setWorkflow(false) the journal entry is not audited and hence it won't show in activity log

solution

1) insert record into sys_journal_field using GlideRecord for your record and verify if the work notes shows in activity log

Example script

var rec = new GlideRecord('sys_journal_field');
rec.initialize();
rec.name = req.getTableName();
rec.value = 'closed your request with approval';
rec.element = 'work_notes';
rec.element_id = req.sys_id;
rec.insert();

 

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar  yes its inserting a record in sys journal table ,  but I couldn't see it get updated in the REQ record activity 

element id is correct, but why its still not get updated ?

@sukran 

If it's still not showing in activity log when you are inserting record using GlideRecord in sys_journal_field then I believe it's not possible to achieve this.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader