I want to update my work notes of my SC task table after each updates on my form(sc_task)

dhineshkumar
Tera Guru

Hi Experts 

I want to update my sc_task table work notes for each update on my sc_task table. 

Thanks in advance.

3 REPLIES 3

sourav1999
Mega Guru

-You can update the work notes of your SC task table after each update on your form by using the Client Scripts in the ServiceNow platform.
-In the Client Scripts, you can use the onChange() function which will be triggered when the form is updated, and use the setWorkNotes() function to update the work notes of the SC task table.
-You can also use the GlideRecord API to update the work notes of the SC task table.
-You can also use the update() method of the GlideRecord API to update the work notes of the SC task table.

 

For asking ServiceNow-related questions try this :

For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.

Link - https://nowgpt.ai/

 

For the ServiceNow Certified System Administrator exams try this :

https://www.udemy.com/course/servicenow-csa-admin-certification-exam-2023/?couponCode=NOW-DEVELOPER

johnfeist
Mega Sage
Mega Sage

Hi DInesh,

Depending on how much information you want in the work note, this can range from pretty simple to a nuisance.  You need an after update business rule.  If all you want is a work note that says that there was an update by a given user, all you need is:

var theUser = gs.getUsername();
var theMessage = "Task has been updated by " + theUser;
current.setValue("work_note", theMessage);
current.update();

That will create your basic work note.  Since the display of the work note includes the date time that the note was created, that should be all you need.  If you want to note what was changed, you will need start comparing values to document that and adjust theMessage accordingly.

 

This has to be an after update rule to avoid the possibility that the update is that the user added a work note.  In a before update script the work note would be over written.  You can do this as a before update rule if you check if the update is a work note and don't bother adding another work note.  In that case, don't include the current.update() statement as it can cause an endless loop.

 

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Using current.update() in an after business rule can also lead to an endless loop, so consider adding current.setWorkflow(false) one line above it.