- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2016 08:37 AM
Hello,
I have written below code to update my approval status and rejection comments on approval table. My state is updated but I am facing issue in updating value in comment field. It is Journal input field.
var approval = new GlideRecord('sysapproval_approver');
approval.addQuery('sysapproval',number);
approval.addQuery('approver',userID);
approval.query();
while(approval.next()){
approval.comment = comments;
approval.state = 'rejected';
approval.updateWithReferences();
}
Thanks you in advance. Help is really appreciated.
Regards,
Vaibhav Desai
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2016 09:16 AM
You know what, your field name is incorrect here. It should be comments and also use update here. You do not need updateWithReferences()
var comments = this.getParameter('sysparm_comments');
var number = this.getParameter('sysparm_number');
var userID = this.getParameter('sysparm_userID');
gs.log(">>>>>>>>>>>>COMMENTS "+comments+" NUMBER "+number+" USER ID "+userID);
var approval = new GlideRecord('sysapproval_approver');
approval.addQuery('sysapproval',number);
approval.addQuery('approver',userID);
approval.query();
while(approval.next()){
approval.comments = comments;
approval.state = 'rejected';
approval.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2016 08:48 AM
Journal field is set like any other field no difference
eg:
current.comments = 'this is an example comment';
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2016 08:56 AM
Hello Anurag,
I found this, Delete or Update Activity log and Journal Field Entries - ServiceNow Guru
Not sure how to use it in my script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2016 09:00 AM
Make sure you have not used setWorkflow(false) , otherwise it will not work. comments wont get updated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2016 09:01 AM
Hello anurag,
Yes i confirm I haven't used setWorkflow(false).