The Zurich release has arrived! Interested in new features and functionalities? Click here for more

whenever line Manager.manager also not approved with in five days then request will be cancelled

Nareshpatel
Tera Expert

when a line manager not approved with in 3 days then the notification goes to linemanager.manager . If linemanager.manager also not approved with in five days( this period line manager should be also able to approve ) , then the request will be cancelled.

Please help anyone to script provide (no flow designer or workflows suggestion).

1 ACCEPTED SOLUTION

If you will provide more details than I may help with the proper script.
But you can check once with this 

var grRITM = new GlideRecod('sc_req_item');
grRITM.addencodedquery('request.request_state=requested^ORDERBYDESCnumber');
grRITM.query();
while(grRITM.next(()) {
      var lineManger = grRITM .u_line_manager; //based upon your field name change this field 
      var lineManagerMang =  grRITM .u_line_manager.manager;  //based upon your field name change this field 
       var grApproval = new GlideRecord('sysapproval_approver');
       grApproval.addencodedquery('sysapproval='+grRITM .sys_id+'^approver='+lineManger +'^ORapprover='+lineManagerMang +'^ORDERBYsys_created_on');
      grApproval.query();
     while(grApproval.next()) {
           var date1 = new GlideDateTime(); //current date
           var createdDate = new GlideDateTime(grApproval.sys_created_on); //approval created date
            var dateDiff = GlideDateTime.subtract(createdDate, date1);
            var days = dateDiff.getDayPart();
          if(days > 4 && grApproval.approver == lineManger ) { //you can change the date value based upon your requirement
              ///you can call a event to trigger the notification and a script action to create a approval request for line manager's manager if this approval request you are note creating from the flow or somewhere
          }
           if (days > 5 && grApproval.approver == lineManagerMang) {
                 write script to cancel the request
           }
}
Your feedback makes the community stronger! If you found this helpful, marking it as the correct answer helps others.
Stay awesome,
Roshnee Dash

View solution in original post

11 REPLIES 11

  1. This script sends reminder to line managers for pending approvals for before 3days,then approval will go line manager's manager which we are going to implement .If line manager's manager also not approved with in five days, then cancel the request.
  2.  

Nareshpatel
Tera Expert

when a line manager not approved with in 3 days then the notification goes to linemanager.manager . If linemanager.manager also not approved with in five days( this period line manager should be also able to approve ) , then the request will be cancelled.

Please help anyone to script provide (no flow designer or workflows suggestion).