Approve/Reject buttons in Approve widget on Self-Service Portal

BigMikeyVegas
Tera Guru

On the Approve widget on the Service Portal index page, I am attempting to either 1. Make the Approve and Reject buttons force a comment or 2. remove the Approve/Reject buttons altogether. We want to keep the 'Options' so that the person can review the the item being approved. I have seen this done for the Approval info widget. My script-fu is not quite there yet, so I have been relying on snippets from other community posts and other areas. Essentially, if we keep the buttons, I need a comments box, and a way to make either just Reject or both Approve and Reject require a comment. 

This is what we currently have. Any assistance is greatly appreciated. My Test instance is in Madrid and my QA/Prod are in London.

 

1 ACCEPTED SOLUTION

BigMikeyVegas
Tera Guru

The answer has been found. There was a reply by @manishm on this post. Edits to the code are in Red. I added an attachment to show the results.

______________________________________________________________________________________

Changes to Approvals Widget that shows up on the index page to capture Rejection Comments:

Server Script 

if (input.op == 'approved' || input.op == 'rejected') {
var app = new GlideRecord("sysapproval_approver");
if (app.get(input.target)) {
app.state = input.op;
if (input.comments) {
app.comments = input.comments;
}
app.update();
}
}

 

Client Controller

function ($scope, spUtil, spUIActionsExecuter, spModal) {

...

$scope.reject = function(id, esigRequired) {
var requestParams = {
username: $scope.data.esignature.username,
userSysId: $scope.data.esignature.userSysId
};

if($scope.data.esignature.e_sig_required && esigRequired) {
spUIActionsExecuter.executeFormAction(ESIGNATURE.REJECT_SYS, "sysapproval_approver" , id, [] , "", requestParams).then(function(response) {
});
} else {
spModal.prompt("Please enter reason for rejection").then(function(rejectReason) {
$scope.data.op = "rejected";
$scope.data.target = id;
$scope.data.comments = rejectReason;
get(); 
});
}
}

...

}

______________________________________________________________________________________

View solution in original post

6 REPLIES 6

sachin_namjoshi
Kilo Patron
Kilo Patron

you can refer below to provide approve, rejection buttons in SP.

 

https://serviceportal.io/create-custom-action-buttons-service-portal/

 

Regards,

Sachin

BigMikeyVegas
Tera Guru

The answer has been found. There was a reply by @manishm on this post. Edits to the code are in Red. I added an attachment to show the results.

______________________________________________________________________________________

Changes to Approvals Widget that shows up on the index page to capture Rejection Comments:

Server Script 

if (input.op == 'approved' || input.op == 'rejected') {
var app = new GlideRecord("sysapproval_approver");
if (app.get(input.target)) {
app.state = input.op;
if (input.comments) {
app.comments = input.comments;
}
app.update();
}
}

 

Client Controller

function ($scope, spUtil, spUIActionsExecuter, spModal) {

...

$scope.reject = function(id, esigRequired) {
var requestParams = {
username: $scope.data.esignature.username,
userSysId: $scope.data.esignature.userSysId
};

if($scope.data.esignature.e_sig_required && esigRequired) {
spUIActionsExecuter.executeFormAction(ESIGNATURE.REJECT_SYS, "sysapproval_approver" , id, [] , "", requestParams).then(function(response) {
});
} else {
spModal.prompt("Please enter reason for rejection").then(function(rejectReason) {
$scope.data.op = "rejected";
$scope.data.target = id;
$scope.data.comments = rejectReason;
get(); 
});
}
}

...

}

______________________________________________________________________________________

It really worked for me !

 

Thank you so much!!

But I have a challenge as attached in the screenshot. I was getting an asterisk after the reason for rejection. May I know what might be the reason I am getting asterisk.find_real_file.png

Hi!!

I have the same problem with the asterisk.

Did you figure out how to fix it?

 

Thanks.