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.

How to access Work Notes value in Client Script

Mounika M
Tera Contributor

Hi Team,

 

I want to access work notes in client script, but i am getting empty value.

var table_name = g_form.getTableName();

var rej_comm = "Cancellation/Closed Incomplete/Rejected Reason: ";


var oldWorkNotes = g_form.getValue('work_notes');
alert('old worknotes: '+oldWorkNotes);
var oldComments = g_form.getValue('comments');
alert('oldComment: '+oldComments);
if (oldWorkNotes != '') {
alert(oldWorkNotes);
alert('oldWorknotes is empty');
var assigneeWrkNotes = "Assignee Comment in brief: " + oldWorkNotes;
g_form.setValue('work_notes', rej_comm + '\n' + assigneeWrkNotes);
} else if (oldComments != '') {
var addi_comments = "Additional Comments: " + oldComments;
g_form.setValue('comments', rej_comm + '\n' + addi_comments);
} else {
alert('in else loop');
g_form.setValue('work_notes', rej_comm);
g_form.setValue('comments', rej_comm);
}
}

I am getting oldWorkNotes  as empty,  could you please help on this!!

 

Thanks in Advance!!!

2 REPLIES 2

rahulpandey
Kilo Sage

Hi Mounika,

Work note is a Journal field, it means it doesn't hold any value hence, you will get blank value on client side. To get value of worknotes, you need to make a glideajax call, and get its value from script include via. Further you can apply your rest of the logic.

You can get worknotes latest values using work_notes.getJournalEntry(-1);

 

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Worknotes dont get saved in the same table , but rather on the journal tables.

So to read it id suggest

Write a display business rule and use the script below

g_scratchpad.oldWN= current.work_notes.getJournalEntry(1);

 

In your client script read it as

g_scratchpad.oldWN

 

-Anurag

-Anurag