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.

Add Case field value as an Additional Comment

MStritt
Tera Guru

Is it possible to have a value entered in a field on a Case, to be added to Activities as an Additional Comment instead of a Work Note? And, for it to only apply to a specific Case view?

7 REPLIES 7

Would I add it to the beginning of the code you provided earlier?

(function executeRule(current, previous /*null when async*/) {
if (current.close_notes) {
// Create a new journal entry in Additional Comments
var journalEntry = new GlideRecord('sys_journal_field');
journalEntry.initialize();
journalEntry.element_id = current.sys_id;
journalEntry.name = 'comments'; 
journalEntry.value = current.close_notes;
journalEntry.insert();
}
})(current, previous);

 

Hi @MStritt,

Use the previous code logic in the if condition block.

if (g_form.getViewName() == 'your_view_name') {
    // Write your logic here
(function executeRule(current, previous /*null when async*/) {
if (current.close_notes) {
// Create a new journal entry in Additional Comments
var journalEntry = new GlideRecord('sys_journal_field');
journalEntry.initialize();
journalEntry.element_id = current.sys_id;
journalEntry.name = 'comments'; 
journalEntry.value = current.close_notes;
journalEntry.insert();
}
})(current, previous);