URL in an Email notification to ESC view of an Approval Task

Linda6
Mega Guru

Dear community,

I'm struggling in finding out how to direct the users who receive an approval notifications to be directed to the ESC view of the approval instead to the backend.

I came across these two articles which were helpful:

URL in an Email notification to portal view of a HR Task 

How to set up email notifications to point to the Service Portal instead of the Platform UI 

 

However, my concern is that when the user clicks on the button to Take me to my Approval, it directs to the ESC, but only to the general view of the To-dos widget (hrm_todos_page), but not the specific approval task/request:

 

Where it directs now:

situationnow.png

 

Desired state would be to open directly the given approval request (in this case it is CHG0030195):

 

situationdesired.png

 

The email script I'm using is as follows:

 

 

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

	var url = '<a href="' + 'esc?id=hrm_todos_page&table=' + current.sys_class_name + '&sys_id=' + current.sys_id + '">Take me to the Approval</a>';

	//template.print("<a href= '"+ url + "'>" + current.number + "</a>"); 
	template.print(url);
		
})(current, template, email, email_action, event);

 

 

 

Can you please help me in correcting my script, so it would direct the user straight to the desired approve request?

 

Thank you and kind regards,

 

Linda

 

13 REPLIES 13

I think the problem is your link var.


Try ....

var link = '/esc?id=hrm_todos_page&table=sysapproval_approver&sys_id=' + current.sys_id;

 

But whatever the case may be... you should DEFINITELY log out the way you have your link var set up now.  It will teach you a lot!

 

Hi Linda, 
we have did it nearly the same way as you did. As we also use dynamic links for requests or incidents in E-Mail scripts, I tried to dynamically create the link with current.sys_class_name to find the sysapproval_approver but it didn't worked. Therefor, instead of the sys_id we hardcopy everything to create the ESC link. For sys_id you can use current.getUniqueValue() . todo_sys_id is not directly needed. At least the links never failed for our approver.

So with your e-mail script this would be the way:

(function runMailScript( current, template, email, email_action, event) {
	var link = 'esc?id=hrm_todo&view=sp&sysparm_tableName=sysapproval_approver&sys_id=' + current.getUniqueValue();
	// Generate Link for ESC Portal Approver View
	template.print('<font face="helvetica">');
	var backgroundColor = 'background-color: #278efc;';
	var border = 'border: 1px solid #0368d4;';
	var color = 'color: #ffffff;';
	var fontSize = 'font-size: 14px;';
	var fontFamily = 'font-family: Helvetica, Arial, sans-serif;';
	var textDecoration = 'text-decoration: none; border-radius: 3px;';
	var webKitBorder = '-webkit-border-radius: 3px;';
	var mozBorder = '-moz-border-radius: 3px;';
	var display = 'display: inline-block;';
	var padding = 'padding: 5px;';
	template.print('<a href="' + link + '"');
	template.print('style="' + backgroundColor + border + color + fontSize + fontFamily + textDecoration + webKitBorder + mozBorder + display + padding);
	template.print('">');
	template.print(gs.getMessage('Take me to my Approval Request'));
	template.print('</a>');
	template.print('</font>');
})(current, template, email, email_action, event);


Let me know if it worked out for you and mark as helpful when it did.

Regards

Elena

Antonio Vidal
Tera Contributor

Not sure if you were able to figure this out  on your own, but I had similar requirements and I finally got it to work using the hrm_todo page and these parameters: ?id=hrm_todo&sysparm_tableName=sysapproval_approver&sys_id=

Sathiskumar_D
Giga Sage

I am experiencing the same issue. Any solution for this?

Hey Sathiskumar_D,

Did you check out my post from Oct 27th?

"Not sure if you were able to figure this out  on your own, but I had similar requirements and I finally got it to work using the hrm_todo page and these parameters: ?id=hrm_todo&sysparm_tableName=sysapproval_approver&sys_id="