ATF: Server side code step help

SD35
Tera Expert

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.

1 ACCEPTED SOLUTION

Ashutosh Munot1
Kilo Patron
Kilo Patron

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

View solution in original post

5 REPLIES 5

Harish Vaibhare
Kilo Guru

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.