escalation button visibility

Evan2
Kilo Guru

Hi All,

 

I have created a widget "Escalate" to trigger escalations through email. But as per requirement I have to make it vidible if-

 

  • Incident is not updated since last 4 days
  • State is not cancelled(8), resolved(6) & closed(7).
  • It should be visible only to caller or opened by user.

I tried doing that and its working partially. It is visible now for every state and after just submitting the incident.

Please find below the script for widget i have tried and help me to fix this.

 

HTML

 

<div>
<!-- your widget template -->
<div class="panel b" ng-if="data.showWidget">
<div class="panel-heading bg-primary">Actions</div>
<div class="panel-body">
<button type="button" class="btn btn-primary btn-block" ng-click="c.openModalEscalate()" ng-if="data.showEsc">Escalate</button>
</div>
<script type="text/ng-template" id="modalEscalate">

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Do you want to escalate?</h4>
</div>
<div class="panel-body wrapper-xl">
<form name="modalEscalate" ng-submit="c.uiAction('esc')">
<input class="btn btn-primary" type="Submit" />

<button class="btn btn-primary" ng-click="c.closeModal()">${Close}</button>

</form>
</div>
</div>

</script>
</div>
</div>

 

Server script

 

(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
// Get table & sys_id
data.table = input.table || $sp.getParameter("table");
data.sys_id = input.sys_id || $sp.getParameter("sys_id");

// Valid GlideRecord
var gr = new GlideRecord(data.table);
if (!gr.isValid())
return;

// Valid sys_id
//
if (!gr.get(data.sys_id))
return;

//Button Visibility
if(data.table == 'incident'|| data.table == 'sc_request'||data.table == 'sc_req_item' ||data.table == 'sc_task' && gr.active == true && (gr.caller_id == gs.getUserID() || gr.opened_by == gs.getUserID()) && gr.incident_state != 6 || gr.incident_state != 7 ||gr.incident_state != 8 ){
data.showWidget = true;
data.showEsc = true;

}
else {
data.showWidget = false;
data.showEsc = false;
}

//input
if (input && input.action) {
var action = input.action;

//Incident table
if (data.table == 'incident') {

if (action == 'esc') {
// gs.addInfoMessage("Incident Escalated-1");
gr.setValue('u_incident_esc', 'true');
gr.comments = "Ticket Escalated";
// gs.addInfoMessage("Incident Escalated-2");
gr.update();
//gs.addInfoMessage("Incident Escalated-3");
gs.eventQueue('incidentEscalation', gr, gr.assigned_to.manager);
gs.addInfoMessage("Incident Escalated");
}
}
}

})();

 

 

Client controller

 

api.controller=function($uibModal, $scope, spUtil) {
/* widget controller */
var c = this;



// c.openModalEscalate = function() {
// c.data.action = "esc";
// c.server.update().then(function() {
// c.data.action = undefined;
// })

// }

c.uiAction = function(action) {
c.data.action = action;
c.server.update().then(function() {
c.data.action = undefined;
});
c.modalInstance.close();
};
c.openModalEscalate = function() {
c.modalInstance = $uibModal.open({
templateUrl: 'modalEscalate',
scope: $scope
});
};
c.closeModal = function() {
c.modalInstance.close();
};

};

 

 

find_real_file.png

 

Please help me to apply all the above visibility conditions.

 

Regards,

Kumar nandan

5 REPLIES 5

diegomatias12
Tera Contributor

Hi Evan

Do you resolve this case?
I'm working on something similiar to this