Bulk Approval in Service Portal

Prathap4
Tera Contributor

Hi Everyone,

 

in service portal i need approve bulk request at time.

Prathap4_0-1687850620990.png

here if i select one or more check box i need to approve. if anyone know this pls help me.
code are below.
HTML code:

<div>
<!-- your widget template -->
  <table border="1px">
    <tr>
     <th class="text-nowrap center" tabindex="0">
  <input type="checkbox" ng-model="data.master_checkbox" ng-click="masterCheckBoxClick();"/>
</th>
         
    <th><button ng-click="sortBy('number')">Number</button> </th>
      <!--<th><button ng-click="sortBy('short_description')">Short Description</button> </th>-->
      <th><button ng-click="sortBy('priority')">State</button> </th>
      <th><button ng-click="sortBy('updated')">Created</button> </th>
      <td ng-if="modifingRecord.sys_id == ticket.sys_id"><button class="btn btn-primary" ng-click="modifyRec(ticket)">Approve</button></td>
      <td ng-if="modifingRecord.sys_id == ticket.sys_id"><button class="btn btn-danger" ng-click="saveRec(ticket)">Reject</button></td>
    </tr>
    <tr ng-repeat="ticket in data.tickets | orderBy:orderField">
      <td class="text-nowrap center" tabindex="0" ng-click="saveRec(ticket)">
              <input type="checkbox" ng-nodel="data.tickets.state"/>
            </td>
      <td>{{ticket.number}}</td>
     <!--<td ng-if="modifingRecord.sys_id == ticket.sys_id"><textarea ng-model="ticket.short_description"></textarea></td>
      <td ng-if="modifingRecord.sys_id != ticket.sys_id">{{ticket.short_description}}</td>-->
      <td>{{ticket.state}}</td>
      <td>{{ticket.created}}</td>
     <!-- <td ng-if="modifingRecord.sys_id != ticket.sys_id"><button class="btn btn-primary" ng-click="modifyRec(ticket)">Modify</button></td>
      <td ng-if="modifingRecord.sys_id == ticket.sys_id"><button class="btn btn-danger" ng-click="saveRec(ticket)">Save</button></td>-->
     <!-- <td><button class="btn btn-primary" ng-click="modifyRec(ticket)">Approve</button></td>
      <td><button class="btn btn-danger" ng-click="saveRec(ticket)">Reject</button></td>-->
      
    </tr>
    
  </table>
</div>
 
Client Script : 
function($scope,spUtil) {
/* widget controller */
var c = this;
$scope.sortBy = function(field){
$scope.orderField = field;
}
$scope.modifyRec = function(ticket){
$scope.modifingRecord = angular.copy(ticket);
}
$scope.saveRec = function(ticket){
$scope.data.modifiedRec = angular.copy(ticket);
spUtil.update($scope);
$scope.modifingRecord = null;
}
spUtil.recordWatch($scope, "incident", "active=true", function(name, data) {
spUtil.update($scope);
});
}
 
Server Side:
(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
 
var tableSys = options.table.toString();
var tableRec = new GlideRecord('sys_db_object');
tableRec.get('sys_id',tableSys);
var tableName = tableRec.name.toString();
if(tableName == '' || tableName == undefined){
//tableName = 'incident';
tableName = 'sysapproval_approver';
}
 
data.tickets = [];
var ticketRec = new GlideRecord(tableName);
ticketRec.addEncodedQuery('state=requested');
ticketRec.addActiveQuery();
ticketRec.setLimit(10);
ticketRec.query();
while(ticketRec.next()){
var ticket = {};
ticket.number = ticketRec.getDisplayValue('document_id');
//ticket.short_description = ticketRec.short_description.toString();
ticket.sys_id = ticketRec.sys_id.toString();
ticket.created = ticketRec.getValue('sys_created_on');
ticket.state = ticketRec.state.toString();
//ticket.short_description = ticketRec.sysapproval_approver.sysapproval.short_description;
data.tickets.push(ticket);
}
 
if(input){
console.log(input);
var modifyTic = new GlideRecord(tableName);
modifyTic.addQuery('sys_id',input.modifiedRec.sys_id);
modifyTic.query();
if(modifyTic.next()){
modifyTic.short_description = "approved";
modifyTic.update();
}
}
 
})();
2 REPLIES 2

Prathap4
Tera Contributor
 

is there a way to filter out the approvals and also have it so that the attachments shows on the same line