How can I add comment as I trigger approval from workflow?

Paul125
Kilo Guru

Hello,

I have more than 10 approvals that goes to different users and groups. These requests generated as user selects variables, in this case I am trying to add comments to the approval form to let user know what he is trying to approve. Please let me know if there is any way to add comments or have a description field. Thanks!

1 ACCEPTED SOLUTION

Paul125
Kilo Guru

Thanks for the reply Bryan. I found a way to add a comment/activities by gliding approval table. To achieve this, I've created a run-script activity right after the approval activity. Once the approval request in place, my script run, look for current item's request and add a comment to let approval user know some information. Do you think this process affect anything or not a best practice to do? Thanks! 

Note: This is only related to one particular Catalog Item.

View solution in original post

6 REPLIES 6

Hi SK,

Here you go..Let me know if you have any questions.

function addTexttoApprovals1(){
	var currentField = current.variables.material_risk_rsp;
	var apprv1 = new GlideRecord("sysapproval_approver");
	apprv1.addEncodedQuery('sysapproval='+current.sys_id+'^state=requested^');
	apprv1.query();
	while (apprv1.next()) {
		var rsp = current.variables.hnb_app_rsp;
		var app = rsp.u_application;
		var appName = current.variables.hnb_app;
		var hnbApp = appName.name;
		var lineofBusiness = app.u_primary_line_of_business;
		var riskOfficer = lineofBusiness.u_segment_risk_officer;
		var rof = apprv1.approver;
		var wflow = apprv1.wf_activity;
		var wf1ow1 = wflow.name;
		
		
		//if (riskOfficer == rof && commn.indexOf('approving/rejecting') != -1){
			if (riskOfficer == rof && wf1ow1 == 'Material Risk field owner approval'){
				apprv1.comments='You are approving/rejecting [Material Risk - '+currentField+ '] field on the application '+hnbApp+'' ;
				apprv1.update();
				
			}
			
		}
	}
	addTexttoApprovals1();

Pratuls
Tera Contributor

Hi Paul,

 

I have a query. As per my understanding, after the approval gets created it suppose to wait at that activity only until the approval is completed then if we put Run Script after it then how it is adding comments once the approval is created and no action has been taken on it.