How to set a work note in a UI action?

anguyen8842
Tera Contributor

I created a client UI action that would a open new change request on press, however I noticed that if I try to set a work note during the creation - the script completely breaks and no record is created. No error is outputted either when i go to system logs. 

 

var change = new GlideRecord("change_request");
change.initialize();
change.short_description = "Test";
change.description = "Test Description";
change.work_notes = "Test Note"; // Ticket is created if this line is commented out
change.insert();

My goal is to create a work note that would be a copy of the description. I can accomplish this through a business rule, but that is overkill and I feel like I should be able to do this with one line of code in the action itself.

 

What's the proper way to set a work note in a UI action?

1 ACCEPTED SOLUTION

Deepak Shaerma
Mega Sage
Mega Sage

Hi @anguyen8842 

Because client side GlideRecord can only handle basic fields like strings and integers, it cannot process Journal fields like work_notes or comments. These fields require server-side processing to generate the journal entries and timestamps.

you should simply uncheck the "Client" box on your UI Action. By unchecking "Client", your script runs entirely on the server. The GlideRecord object will then have full access to the Journal field processor, and your exact code will work immediately.


Happy to help! If this resolved your issue, kindly mark it as the correct answer   and Helpful 👍 and close the thread 🔒 so others can benefit too.
Warm Regards,
Deepak Sharma
Community Rising Star 2025

View solution in original post

3 REPLIES 3

Deepak Shaerma
Mega Sage
Mega Sage

Hi @anguyen8842 

Because client side GlideRecord can only handle basic fields like strings and integers, it cannot process Journal fields like work_notes or comments. These fields require server-side processing to generate the journal entries and timestamps.

you should simply uncheck the "Client" box on your UI Action. By unchecking "Client", your script runs entirely on the server. The GlideRecord object will then have full access to the Journal field processor, and your exact code will work immediately.


Happy to help! If this resolved your issue, kindly mark it as the correct answer   and Helpful 👍 and close the thread 🔒 so others can benefit too.
Warm Regards,
Deepak Sharma
Community Rising Star 2025

Ankur Bawiskar
Tera Patron
Tera Patron

@anguyen8842 

I won't recommend GlideRecord in client side as it's not best practice.

You can use GlideAjax and then it will help in setting all the fields including work_notes

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@anguyen8842 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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