Group tasks widget in Service Portal

 



widget takes you back into classic UI view when the task number is clicked. Lists all ticket types assigned to the group the logged in user belongs to

script - HTML

<div class="panel panel-default"> <div class="panel-heading clearfix"> <div class="pull-right"> <a class="btn btn-default btn-sm" ng-click="showFilters = !showFilters"><i class="fa fa-filter"></i></a> </div> <div class="panel-title">My Groups Tasks</div> </div> <div class="panel-body" ng-show="showFilters"> <form class="form-inline"> <div class="form-group"> <label for="textSearch">Search</label> <input id="textSearch" class="form-control" type="text" ng-model="textSearch" placeholder="Search... "/> </div> <div class="form-group"> <label for="taskType">Task type</label> <select id="taskType" class="form-control" ng-model="table"> <option value="">All</option> <option ng-repeat="table in tables" value="{{table}}">{{table}}</option> </select> </div> <div class="form-group"> <label for="assignment">Assignment</label> <select id="assignment" class="form-control" ng-model="assigned"> <option value="">All</option> <option value="true">Unassigned</option> </select> </div> </form> </div> <table class="table table-striped"> <thead> <tr> <th class="col-xs-6" ng-click="sortBy('number')"> Task <span class="sortorder" ng-show="propertyName === 'number'" ng-class="{reverse: reverse}"></span> </th> <!--<th class="col-xs-2">Number</th> <th class="col-xs-4">Short description</th>--> <th class="col-xs-2" ng-click="sortBy('state')"> State <span class="sortorder" ng-show="propertyName === 'state'" ng-class="{reverse: reverse}"></span> </th> <th class="col-xs-2" ng-click="sortBy('assignment_group')"> Assignment group <span class="sortorder" ng-show="propertyName === 'assignment_group'" ng-class="{reverse: reverse}"></span> </th> <th class="col-xs-2" ng-click="sortBy('assigned_to')"> Assigned to <span class="sortorder" ng-show="propertyName === 'assigned_to'" ng-class="{reverse: reverse}"></span> </th> </tr> </thead> <tbody> <tr ng-repeat="task in tasks | orderBy:propertyName:reverse | filter: {$:textSearch,unassigned:assigned,tableName:table}"> <!--<td class="col-xs-2">{{task.number}}</td> <td class="col-xs-4">{{task.short_description}}</td>--> <td class="col-xs-6"> <p class=""><a href="/nav_to.do?uri={{task.table}}.do?sys_id={{task.sys_id}}">{{task.short_description}}</a></p> <span>{{task.number}}</span> </td> <td class="col-xs-2">{{task.state}}</td> <td class="col-xs-2">{{task.assignment_group}}</td> <td class="col-xs-2">{{task.assigned_to}}</td> </tr> </tbody> </table> </div>

script: CSS

.sortorder:after { content: '\25b2'; // BLACK UP-POINTING TRIANGLE } .sortorder.reverse:after { content: '\25bc'; // BLACK DOWN-POINTING TRIANGLE } .form-group{margin-right:1em;}

script: client script

function($scope) { var c = this; $scope.tables = c.data.tables; $scope.tasks = c.data.tasks; $scope.propertyName = 'number'; $scope.reverse = true; $scope.showFilters = true; $scope.sortBy = function(propertyName) { $scope.reverse = ($scope.propertyName === propertyName) ? !$scope.reverse : false; $scope.propertyName = propertyName; }; }

script: option schema

[{"name":"title","section":"Presentation","default_value":"My Requests","label":"Title","type":"string"},{"name":"show_view","section":"Behavior","default_value":"true","label":"Show View","type":"boolean"},{"hint":"Number of items per page","name":"items_per_page","section":"Behavior","default_value":"15","label":"Items per page","type":"integer"}]

script: server script



(function() { data.tasks = []; var tableList = []; var gr = new GlideRecord("task"); gr.addActiveQuery(); gr.addEncodedQuery("assignment_group=javascript:getMyGroups()"); gr.addQuery("sys_class_name", "!=", "sc_request"); gr.query(); while(gr.next()){ tableList.push(gr.getClassDisplayValue()); var object = {}; object.table = gr.getValue("sys_class_name"); object.tableName = gr.getClassDisplayValue(); object.sys_id = gr.getUniqueValue(); object.number = gr.getDisplayValue("number"); object.short_description = gr.getDisplayValue("short_description"); object.state = gr.getDisplayValue("state"); object.assignment_group = gr.getDisplayValue("assignment_group"); object.assigned_to = gr.getDisplayValue("assigned_to"); object.unassigned = ''; if(gr.getDisplayValue("assigned_to") == '') object.unassigned = true; data.tasks.push(object); } data.tables = new ArrayUtil().unique(tableList); })();







Comments

Popular posts from this blog

Running transform maps asynchronously

GlideRecord setValue

Post a command to the ECC queue for the mid server to initiate a powershell file copy