Approval not geeting rejected
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 01:42 AM
Hello Experts,
In the sysapproval_approver table if we want to reject a request, first we have to add some comments and after that we can reject. Same thing i am doing via script and it is not Working. Can anyone tell me where i am doing wrong.
var app = new GlideRecord('sysapproval_approver');
app.addQuery('document_id', current.sys_id);//current is change requests sysid
app.addQuery('state', 'requested');//finding the record which are in requested state
app.query();
if(app.next())
{
gs.log("inside");//it is printinting
app.setValue('state', 'rejected');
app.setValue('comments', 'Rejected');
app.update();
}
The approval is not getting rejected.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 01:48 AM - edited 11-24-2023 01:51 AM
Hi Deepika,
Can you replace
app.addQuery('document_id', current.sys_id);//current is change requests sysid
with
app.addQuery('sysapproval', current.sys_id);//current is change requests sysid
Also, I assume you are using above script in BR and not scheduled job or Background script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 02:17 AM
yes @Jaspal Singh . i am using a BR. the query and all is going fine because it is going inside the if loop and printing the log statement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 03:23 AM
Hi @deepika46
Please use below:
var app = new GlideRecord('sysapproval_approver');
app.addQuery('document_id', current.sys_id);//current is change requests sysid
app.addQuery('state', 'requested');//finding the record which are in requested state
app.query();
if(app.next())
{
gs.log("inside");//it is printinting
app.setValue('state', 'rejected');
app.comments = 'Rejected'; // setValue will not set value of Journal field
app.update();
}
setValue() method is not supported for Journal Fields.
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 02:20 AM
i will update that addquery and try now