Widget button in service portal my request page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2022 08:31 PM
Hi all so I have a task , creation of widget button on (my request page) of service portal.
The buttons are (Accept resolution) and (Reject resolution).
This buttons should be display only when incident state is resolved.
When clicking on “Accept Resolution” button, the incident state must be updated to Closed with an additional comments written : “Resolution accepted by the user”.
When clicking on Reject Resolution, a popup should be displayed with “Additional Comments” to be populated by the user. Then the incident state must be updated to “Work In Progress” and assignment group must be notified.
I created buttons using HTML and CSS but I have problem with client and server side script. can someone help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2022 03:25 AM
Create a widget global scope) with below code and place it on "ticket" page (service portal standard ticket scope):
HTML:
<div ng-if="data.show">
<button id="accept" ng-click="c.accept()">Accept</button>
<button id="reject" ng-click="c.reject()">Reject</button>
</div>
Server:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
var inc = new GlideRecord('incident');
inc.addQuery('sys_id', $sp.getParameter('sys_id'));
inc.query();
if (inc.next()) {
if ($sp.getParameter('table') == 'incident' && inc.state == 6) {
data.show = true;
}
if (input.action == 'accept') {
inc.state = 7; // setting state to close
inc.comments = "test"; // add your comments
inc.update();
}
else if(input.action=='reject')
{
inc.state=2; // in progress state
inc.comments= input.add_comments;
inc.update();
}
}
})();
Client:
api.controller = function(spModal) {
/* widget controller */
var c = this;
c.accept = function() {
c.data.action = 'accept';
c.server.update();
};
c.reject = function() {
spModal.open({
title: 'Additional Comments',
message: 'Additional Comments',
input: true,
value: c.name
}).then(function(name) {
c.data.add_comments =name;
c.data.action = 'reject';
c.server.update();
});
};
};
The button will be visible for resolved incidents.
Please mark the answer correct/helpful accordingly.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2022 10:32 PM
@SAM321 did this work for you?
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2023 01:37 AM
@RaghavSh the task is paused ..once i restart it i let u know sir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2022 10:49 PM
@RaghavSh yes button should visible on resolved incidents
i attached HTML, Client and server script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2023 01:55 AM
@RaghavSh I have doubt in (maintenance plan) task...I don't know how it works..can u give some ideas on it.