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.

Work notes is not populating via setValue()

123456789456123
Kilo Contributor

This might be simple but I have never had to work with journal entries before. I was wondering if they behave differently that normal string fields. Here is an example/problem I am facing:

I would like to update the Work Notes field but am having no success. Eventually this will be run from a workflow script but currently I am testing this in a business rule.

var info = 'data';

var gr = new GlideRecord('table name here');

gr.initialize();

//see below

gr.insert();

gr.update();

                  Below are the multiple way I have tried to insert data into the work notes field with zero luck.

gr.setValue('work_notes', info);

gr.setValue('work_notes', 'data');

current.work_notes = info;

current.work_notes.SetJournalEntry(info);

If anyone could tell / explain to me what it is that I am doing wrong would be really helpful.

Thank you.

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi Ben,



Try using



gr.work_notes='Data';



find_real_file.png


View solution in original post

6 REPLIES 6

Ximizu
Mega Guru

instead of using

gr.setValue('work_notes', 'data'); //setValue does not work for field of type journal input

you can use

gr['work_notes'] = 'data';

 

This last syntax is especially useful when 'work_notes' is contained in a variable.

Exemple

var fieldName = 'work_notes';
gr[fieldName] = 'data';

 

Ximizu

http://ximizu.io

 

 

Nayan Mahato
Tera Guru

Simply assign the value directly but make sure to make it a string.

 

inc.work_notes = value + "";

or 

inc.work_notes = value .toString();

Regards,

Nayan