Email Script: Navigate Link on email to HR agent workspace instead of Servicenow Portal

Kachu
Kilo Sage

Hi everyone ,

I have This below email script to navigate the Tasks to the Service portal when clicked on email notification. For The Agents who work from the Workspace wants that link to navigate to workspace.

I wrote this script to navigate to HRM to-do summary page. Can any one help how can i make modifications so that it navigates to specific record on agent workspace & If it is IT ticket then should go IT Agent workspace and if it is HR then HR agent workspace.

Thanks.

Here is the script i used

var recordClass = current.sys_class_name;
	var sysID = current.sys_id;
	var ticketPage = '';
	if (recordClass.indexOf('sn_hr_') > -1){
		ticketPage = 'hrm_ticket_page';
	} else {
		ticketPage = 'ticket';
	}
	
	var recordURL = "/sr?id=" + ticketPage + "&table=" + recordClass + "&sys_id=" + sysID;	
	template.print('<strong><font size="3" color="#000000" face="helvetica"><a href="' + recordURL + '">' + current.getValue("number") + '</a></font></strong>\n');

})(current, template, email, email_action, event);
1 ACCEPTED SOLUTION

Anil Lande
Kilo Patron

Hi,

You can update URL line like below:

var recordURL = "/sr?id=" + ticketPage + "&table=" + recordClass + "&sys_id=" + sysID;	

 

var recordClass = current.sys_class_name;
	var sysID = current.sys_id;
// cooment below 6 lines if not required
	var ticketPage = '';
	if (recordClass.indexOf('sn_hr_') > -1){
		ticketPage = 'hrm_ticket_page';
	} else {
		ticketPage = 'ticket';
	}
	
	var recordURL = "/now/workspace/agent/record/" + recordClass + "/" + sysID; // update this line only	
	template.print('<strong><font size="3" color="#000000" face="helvetica"><a href="' + recordURL + '">' + current.getValue("number") + '</a></font></strong>\n');

 

Thanks
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

6 REPLIES 6

shloke04
Kilo Patron

Hi,

You need to replace your line highlighted below to the modified one:

Current Line:

var recordURL = "/sr?id=" + ticketPage + "&table=" + recordClass + "&sys_id=" + sysID;	

Modified Line:

var recordURL = "/now/workspace/agent/home";	

I do not have HR Agent Workspace installed in my PDI, but you can open the HR Workspace module and then just replace it after now.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

This one worked too..!!

Hi @Kachu 

Glad that it worked for you. I think by mistake you have marked your own answer as correct.

Can you please mark my answer as correct and close this thread for others.

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Anil Lande
Kilo Patron

Hi,

You can update URL line like below:

var recordURL = "/sr?id=" + ticketPage + "&table=" + recordClass + "&sys_id=" + sysID;	

 

var recordClass = current.sys_class_name;
	var sysID = current.sys_id;
// cooment below 6 lines if not required
	var ticketPage = '';
	if (recordClass.indexOf('sn_hr_') > -1){
		ticketPage = 'hrm_ticket_page';
	} else {
		ticketPage = 'ticket';
	}
	
	var recordURL = "/now/workspace/agent/record/" + recordClass + "/" + sysID; // update this line only	
	template.print('<strong><font size="3" color="#000000" face="helvetica"><a href="' + recordURL + '">' + current.getValue("number") + '</a></font></strong>\n');

 

Thanks
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande