
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2020 04:09 AM
I am trying to write a server side code step to approve a record in the sysapproval_approver table.
I am new to ATF hence would require help to write this server side code.
Before you ask why I am using server side code instead of record update or UI action, the answer is it does not work due to customizations.
I am able to open the existing approval record in the previous step. I know we have to utilize the step sys_id somewhere hence notified you.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2020 04:28 AM
Hi,
In Server Side Script you can just query the approval table and approve the current record as below:
var grApprov = new GlideRecord('sysapproval_approver');
// Sys Id of the Change
grApprov.addQuery('document_id',steps('076e2301db2113048812644a4b961976').record_id); //This is your step sysid where you have sys id of record to be approved.
// Sys id of my user
grApprov.addQuery('approver','cb8e5a8cdbb153008812644a4b96195b');
grApprov.query();
if (grApprov.next())
{
grApprov.state = 'approved';
grApprov.update();
}
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2020 04:31 AM
Hi,
write below server side code .
var gr=new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval','recordnumber');// for which record should be approved
gr.addQuery('approver','approver name'); // provide approver name.
gr.query();
if(gr.next())
{
gr.state = 'approved';
gr.update();
}
Kindly Mark helpful and correct if it works.
Thanks.