Making rejection comment mandatory on service portal

Ankita Gupte
Kilo Sage

I already have a Approve and reject widget on service portal like this

find_real_file.png

Now I only want to make rejection comment mandatory if approver rejects the request with the pop up if they don't fill in the rejection comment. Kindly guide me as I am new to service portal area.

6 REPLIES 6

Brad Bowman
Kilo Patron
Kilo Patron

Hi Ankita,

First you will need to clone the Approvals widget.

In your copy, add the spModal directive to the existing first line of the Client controller script:

function ($scope, spUtil, spUIActionsExecuter, spModal) 

Then you will need to modify the reject function in the Client controller script something like this:

$scope.reject = function(id, esigRequired) {
		
		spModal.open({
			title: 'Reject Approval',
			message: 'Please enter your reason for rejection, note this will be communicated with the requestor',
			input: true,
			value: $scope.name
		}).then(function(name) {
			$scope.name = name;
			
			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 {
				$scope.data.op = "rejected";
				$scope.data.target = id;
				$scope.data.reject_comment = "Rejection reason: " + $scope.name;
				get();
			}
		});
	};

 Then you will need to update the input on the server script something like this:

if (input) {
	// update pagination
	currentPage = input.pagination.currentPage;
	initRow = (currentPage * maxNumberOfItemsInTheList);
	lastRow = initRow + maxNumberOfItemsInTheList;
	
	if (input.op == 'approved' || input.op == 'rejected') {
		var app = new GlideRecord("sysapproval_approver");
		if (app.get(input.target) && app.state.canWrite()) {
			app.state = input.op;
			if(input.op == 'rejected')
			{
				app.comments = input.reject_comment;
			}
			app.update();
		}
	}
}

 

I have clone widget, but will you please guide me how to add it to spModal directive

Sure, that's just line 1 of the Client controller section.  Everything is already there except the last parameter.  I'll update the above instructions to clarify that.

These help me to achieve pop for bulk approvals. Thanks alot.

but the rejection comment is single line text. I want multiple line text. can we achieve that.