Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to check if there are new additional comments from a certain user

Alcaine
Kilo Contributor

Hello, i've been creating some Notifications for actions like "New additional comments by (opened_by)" and i was trying to do something like this to check if the commenting user is the one that opened the request

var currentUser = gs.getUserID();
var openedBy = current.opened_by;

Then, i wanted to check if new comments have been added with :

var newComments = previous.additional_comments != current.additional_comments ? true : false;

and finally, deciding if the notification will be triggered with : 

if ((currentUser == openedBy) && newComments){
	answer = true;
}

I know additional_comments is a Journal field, but since i only wanted to check for differences (i dont care about the content) i thought i could simply use current and previous, but it doesn't seem to work.

How could i write a condition that checks if there are new comments, and if they were written by a certain user?

Could i combine the Conditions builder with the Advanced condition script?  that way i would only need to write a script that checks the user, and let the simple Condition check for additional comments changes.

 

Thank you kindly!

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Alcaine,

Try as current.comments.changes() //This will return true if new comments are added to the form or not.

View solution in original post

1 REPLY 1

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Alcaine,

Try as current.comments.changes() //This will return true if new comments are added to the form or not.