Need to introduce withdraw case button on service portal
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi All,
We need to introduce withdraw case button as below:
As of now button is visible but on click of button page is redirecting to undefined.
Ideally on click of button, subsequent case should be cancelled and its approvals should be no longer required without affecting any case state and its approvals.
Technical details:
widget - Request Ticket Action
html - <div>
<button name="withdraw" ng-disabled="c.withdraw" ng-click="c.redirectTowithdraw()" class="btn btn-primary btn-block ng-binding ng-scope">
Withdraw Request
</button>
</div>
server script:
(function() {
var tableName = $sp.getParameter('table');
var recordId = $sp.getParameter('sys_id');
if(tableName && recordId) {
var recordGr = new GlideRecord(tableName);
recordGr.get(recordId);
}
if(input && input.withdraw) {
data.resubmit_url = new xxxxUtils.setWithdrawReq(recordGr);
}
})();
client script:
api.controller=function() {
/* widget controller */
var c = this;
c.withdraw = false;
c.redirectTowithdraw = function() {
c.withdraw = true;
c.server.get({
withdraw: true
}).then(function(r) {
top.window.location = r.data.resubmit_url;
});
};
};
Script include:
var PANFUtils = Class.create();
PANFUtils.prototype = {
initialize: function() {
},
showWithdrawButton: function(xxxxGr) {
if (xxxxGr.state == 1 || xxxxGr.state == 10 || xxxxGr.state == 18) {
return true;
} else {
return false;
}
},
setWithdrawReq: function(xxxxGr) {
var sysID= xxxx.sys_id;
var cs = new GlideRecord('xxxx_table');
cs.addEncodedQuery('sys_id',sysID);
cs.query();
while(cs.next())
{
var grAppTask = new GlideRecord('sysapproval_approver');
var grAppTaskencodedqur = "sysapproval=" + cs.sys_id + "^state=requested";
grAppTask.addEncodedQuery(grAppTaskencodedqur);
grAppTask.query();
if (grAppTask.next()) {
grAppTask.state = 'not_required';
grAppTask.comments = "Case is withdraw from requestor.";
grAppTask.update();
}
cs.state = 7;
cs.approval = "rejected";
cs.comments = "Case is withdraw from requestor.";
}
cs.update();
// var url = gs.getProperty('glide.servlet.uri') + "esc?id=my_requests";
// return url;
},
type: 'xxxxUtils'
};
This is somehow not working, please help if i am missing something?
Thanks,
Sri
0 REPLIES 0