- 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 09:00 AM
Any speacial reason for using updateWithReferences instead of update?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2016 09:11 AM
Hi anurag,
No particular reason. even with update also it doesn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2016 09:16 AM
this is the second time this week someone said the same thing...for the same question = updateWithReferences
try to run this
var approval1 = new GlideRecord('sysapproval_approver');
approval1.addQuery('sysapproval.sys_d',number); //Make sure number is a sysid, else modify to sysapproval.number
approval1.addQuery('approver',userID); //also userId should be sys_id
approval1.query();
while(approval1.next()){
gs.log('haha');
approval1.comment = comments;
approval1.state = 'rejected';
approval1.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2016 09:02 AM
In your code, sysparm_number gets the sys_id right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2016 09:10 AM
yes. Filters are working and i guess because of that only my state of approval is getting changed.