- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 01:21 PM
Hi all,
we have a custom table with few fields. Requirement is to the change one of the String fields (say Review comment u_review_comments) to a Journal input field to track changes to this field. I created a new Journal_input field. Its working fine. Now, i need to copy the values of Review Comment string field (max length=1000) to this new field u_review_comment . i wrote the following script and ran it in background scripts. Its not working. Any input is appreciated. I am in Helsinki patch 11.
var csi = new GlideRecord('XXX');
//csi.addQuery('u_number', 'CSI0001043');
csi.query();
while(csi.next()){
gs.print('count ' + csi.getRowCount());
var comment = csi.u_review_comments;
gs.print('comment ' + comment);
csi.u_review_comment = comment;
csi.update();
}
the rowcount and comment variable have data show data, the value is just not coming over to journal field meaning its not showing in activity. If i just pass a string like csi.u_review_comment = 'testing'; it works.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 01:37 PM
hi Ajit,
use the following :
var csi = new GlideRecord('XXX');
//csi.addQuery('u_number', 'CSI0001043');
csi.query();
while(csi.next()){
gs.print('count ' + csi.getRowCount());
var comment = csi.u_review_comments;
gs.print('comment ' + comment);
csi.u_review_comment.setJournalEntry(comments);
csi.update();
}
i have replaced csi.u_review_comment = comment; with csi.u_review_comment.setJournalEntry(comments);nts);
Please mark it as correct if helpful
Pk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 01:35 PM
Hello Ajit,
Change line from var comment = csi.u_review_comments;to var comment = csi.u_review_comments.getJournalEntry(-1);
Using Journal Fields - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 05:18 PM
sorry i thought i had already replied to your comment Pradeep. getJournalEntry(-1) did not work. its gives me 'undefined'. Original Review Comments (u_review_comments) is a string field. i did not knw about the JournalEntry functions. i checked it and it works only for Journal fields. since review comments is a string it did not work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 05:31 PM
You are right Ajit. It will only work for Journal entry fields. I thought the field you are referring to is a journal field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 01:37 PM
hi Ajit,
use the following :
var csi = new GlideRecord('XXX');
//csi.addQuery('u_number', 'CSI0001043');
csi.query();
while(csi.next()){
gs.print('count ' + csi.getRowCount());
var comment = csi.u_review_comments;
gs.print('comment ' + comment);
csi.u_review_comment.setJournalEntry(comments);
csi.update();
}
i have replaced csi.u_review_comment = comment; with csi.u_review_comment.setJournalEntry(comments);nts);
Please mark it as correct if helpful
Pk