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

Uncle Rob
Kilo Patron

1)  Can you manually construct the URL to make sure it works?  (ie. are you sure you have the parameters right?)
2)  Have you logged out the value of your url variable to ensure its outputting the string you want?

Hello @Uncle Rob ,

I constructed it as follows:  /esc?id=hrm_todos_page&table=sysapproval_approver&sys_id=${sys_id}

And the result is, sys_id is missing from the URL:

 

situationsysidmissing.png

 

Did not log the value of the URL, not sure how to do that, as I've got no experience with this so far, will do my research.

/esc?id=hrm_todos_page&table=sysapproval_approver&sys_id=${sys_id}

 

Don't do teh ${sys_id}.   Just copy the actual sys_id of a record you'd expect that page to display and see if it works.  If it doesn't then your URL isn't structured correctly.

 

To log something ....
gs.info("My URL is " + url);

 

Then check your system log files for entries that start with "My URL is"


MORE ON LOGGING
Debugging Scripts
gslog scoped & global

Hi again @Uncle Rob 

I have put together now this email script, that creates a nice button, too, however I still am unable to find out how to modify the link variable so it takes me to the ESC view of the record... for backend it works as expected:

(function runMailScript( current, template, email, email_action, event) {
	var link = 'nav_to.do?uri=%2F' + current.getLink(); //how to modify this in order to direct the user to the ESC 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);

Would you maybe have any advice for me?

Thank you..