How to create cancel button in RITM form in ITIL view and also How to create cancel button in RITM form in Service Portal and that condition to be met is when approval will approve the RITM then cancel button should not be there.

Sravani Gorle
Kilo Contributor
can anyone explain it in detailed way
1 ACCEPTED SOLUTION

Hi,

here you are not setting the approval value properly

jr.setValue('approval', 'requested');

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

16 REPLIES 16

Sravani Gorle
Kilo Contributor

Hi Ankur,

           Can you please give me a suggestion that how to create cancel RITM button in Service Portal Page..

find_real_file.png

Hi Sravani,

the page you are showing is ticket page.

sharing few links on how to add button on ticket page

Is it possible to have UI Actions on the ticket portal page?

https://community.servicenow.com/community?id=community_question&sys_id=c06a1df9db6fa740f21f5583ca96...

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Sravani Gorle
Kilo Contributor

Hi Ankur,

We have gone through it and first we checked it for incident table then it is working but when we glide that table to request item it is getting an error..

HTML

<div class="panel panel-default">
<div class="panel-heading">Actions</div>
<div class="panel-body">
<button type="button" class="btn btn-default btn-block" style="background-color:Cyan;color:Black" ng-click="c.uiAction('cancel')">Cancel </button>
</div>
</div>

CLIENT SCRIPT

function ($uibModal, $scope, spUtil) {
var c = this;

$scope.$on('record.updated', function(name, data) {
spUtil.update($scope);
});

c.uiAction = function(action) {
c.data.action = action;
c.server.update().then(function() {
c.data.action = undefined;
spUtil.addInfoMessage("RITM has been Cancelled", 3000);
});
c.modalInstance.close();
};
c.openModalResolve = function() {
c.modalInstance = $uibModal.open({
templateUrl: 'modalTemplateResolve',
scope: $scope
});
};
c.closeModal = function() {
c.modalInstance.close();
};
}

SERVER SCRIPT

(function() {

// 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 == 'sc_req_item' && gr.approval==requested&& (gr.u_requested_for == gs.getUserID() || gr.opened_by == gs.getUserID())){
data.showWidget = true;
data.showResolve = true;

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

//input
if (input && input.action == 'CancelRITM') {

// If Requested item
if (data.table == 'sc_req_item') {

var jr = new GlideRecord('sc_req_item');
jr.get(data.sys_id);
jr.setValue('approval', requested);
jr.setValue('state', 4);
jr.update();
}
}
})();

find_real_file.png

Hi,

I would suggest to create new question for this so that others are not confused as this question is already answered.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi,

here you are not setting the approval value properly

jr.setValue('approval', 'requested');

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader