Make the comments mandatory when rejecting the Approval

Black Coder
Tera Guru

In the below widget when user click the reject button we have to show the pop up asking reason for cancellation and it should be copied to request's work notes

 

The widget name is "approval info "

 

 

hi.PNG

2 REPLIES 2

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Black Coder ,

 

Doesn't this happen OOTB like whenever anyone rejects the approval they are asked for mentioning the reason & it gets captured in the worknotes/comments.?

 

 

Thanks,

Danish

 

Mayur2109
Kilo Sage
Kilo Sage

Hi @Black Coder ,

We had similar requirements to add worknotes if user rejects approval. We have cloned the OOB Approval Info widget & done the changes on the client script as,

 

 

function ($scope, spUIActionsExecuter, spUtil, spModal,$window) {
	var c = this;

	var ESIGNATURE = {
		"approved": "cbfe291147220100ba13a5554ee4904d",
		"rejected": "580f711147220100ba13a5554ee4904b"
	};

	//spUtil.recordWatch($scope, "sysapproval_approver", "state=requested^sys_id="+ c.data.sys_id);

	c.action = function(state) {
		if(c.data.esignature.e_sig_required) {
			var requestParams = {
				username: c.data.esignature.username,
				userSysId: c.data.esignature.userSysId
			};
			spUIActionsExecuter.executeFormAction(ESIGNATURE[state], "sysapproval_approver" , c.data.sys_id, [] , "", requestParams).then(function(response) {
			});
		} else {
			if(state=='rejected'){

				spModal.prompt("Please enter rejection details", c.name).then(function(name) {
					c.name = name;

					if (c.name == null || c.name == "")
					{
						//Do Nothing
					}
					else{

						c.data.op = state;
						c.data.state = state;
						c.data.rcomments=c.name;
						c.server.update();
					}
				});
			}
			else{
				c.data.op = state;
				c.data.state = state;
				c.server.update();
			}
		}
	}
}

 

 

Server side changes

 

var recGr = new GlideRecord('tablename');
	
if (input && input.op) { 
		gr.state = input.op;
		if(input.op=='rejected' && gr.state.changesTo('rejected'))
		{
			gr.comments = input.rcomments;
			
			if(recGr.get(data.reqSys_id)){			
				recGr.work_notes =input.rcomments;
				recGr.update();
			}
		}
		gr.update();

	}

 

 

While creating link for approval you need to pass parameters such as page id, table id & approval record's sys ID refer the approval link for OOB widget. 

 

Please check and Mark Helpful and Correct if it really helps you.

Regards,
Mayur Shardul