Authorized to Access

MK-p
Tera Contributor

Enable provision to move change back to access from Authorized and cancel all requested approval.

1 ACCEPTED SOLUTION

Runjay Patel
Giga Sage

HI @MK-p ,

 

You can follow below steps to do.

  1. Go to change model and add Authorized to Access.
  2. RunjayPatel_0-1735834460852.png

     

  3. Now create on UI action on change request and use below code.

 

var approval = new GlideRecord('sysapproval_approver');  
      approval.addQuery('sysapproval', current.sys_id);
      approval.addQuery('state', 'requested');  
      approval.query();  
if(approval.next()){
  approval.state = 'rejected';
  approval.comments = "Cancelled by " + user;
  approval.update();

} 

current.state=-4;
current.update();

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

View solution in original post

1 REPLY 1

Runjay Patel
Giga Sage

HI @MK-p ,

 

You can follow below steps to do.

  1. Go to change model and add Authorized to Access.
  2. RunjayPatel_0-1735834460852.png

     

  3. Now create on UI action on change request and use below code.

 

var approval = new GlideRecord('sysapproval_approver');  
      approval.addQuery('sysapproval', current.sys_id);
      approval.addQuery('state', 'requested');  
      approval.query();  
if(approval.next()){
  approval.state = 'rejected';
  approval.comments = "Cancelled by " + user;
  approval.update();

} 

current.state=-4;
current.update();

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------