How to access Activities field value from de-duplication tasks using script.

HrishabhKumar
Kilo Sage

Take a look at the highlighted field in the screenshot below. This is a de-duplication task record.

Screenshot 2025-05-28 at 3.50.36 PM.png

 

How can I access this field using a script.

ex. I want to write a background script and print the value in the that field, how to do that?

3 REPLIES 3

Mark Manders
Mega Patron

That's the activity log, showing you what was entered in the work notes. It is against any best practice to update the journal fields through script, because they are there for audit reasons. You can just update the work notes again with the value you want in there. It will add them on top of the current one.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Nishant8
Giga Sage

Hello @HrishabhKumar, Work Note values can be accessed using getJournalEntry() method. for e.g.

current.work_notes.getJournalEntry(-1); // returns all the work notes entries.
current.work_notes.getJournalEntry(1); // returns the last work notes entry
 
above examples can be used in Business rules, hence 'current' is used. If you want their values to print/copy somewhere using any other script, you can create GlideRecord accordingly, for e.g
var incGR = new GlideRecord('incident');
incGR.get('<Sys_Id>');
incGR.query();
var notesEntry = incGR.work_notes.getJournalEntry(-1);
gs.info(notesEntry);
var arr = notesEntry.split("\n\n"); \\ values are new line delimited  
for (var i = 0; i < arr.length; i++)                
  gs.info(arr[i]);
 
Regads,
Nishant
 

Ankur Bawiskar
Tera Patron
Tera Patron

@HrishabhKumar 

it's an activity log for work_notes field on your form and shows what was entered in it

You can access the field using glideRecordObject.work_notes.getJournalEntry(1)

Can you share what background script you wrote and what's not working?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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