Set default values in email client from script

brumiou
Mega Guru

Hi,

 

I'm opening an email client window from a ui macro (the purpose is to have a mail icon next to a field).

To open the client I'm using this script :  

 


var id = g_form.getUniqueValue();
popupOpenEmailClient("email_client.do?sysparm_target=incident&sysparm_table=incident&sysparm_sys_id=" + id + "&sys_uniqueValue=" + id);
}


It works fine.

 

But now I want to set the value of the from, to ans subject field.

I've tried a lot of thing, but without any chance.

 

Do you know a way to set the value of these fields in the mail client popup?

 

Thanks a lot

 

rgds

 

Xavier

1 ACCEPTED SOLUTION

brumiou
Mega Guru

Hi,



maybe it can help somebody, but I've managed to do it.


I've created a field called u_client_mail_type as a choice field with different velues in it : assigned_to, technical_correspondant, user.


For each value I've created a client mail template with this field and value in the condition.



And in the ui macro, I simply call the popupOpenEmailClient like that :





popupOpenEmailClient("email_client.do?sysparm_table=incident&sysparm_sys_id="+id+"&sysparm_target=incident&sys_target=incident&sys_uniqueValue="+id+"&sys_row=0&sysparm_encoded_record=&incident.u_client_mail_type=assigned_to&sysparm_stack=no");



the important part is the incident.u_client_mail_type=assigned_to at the end of the url, to select the template I need.



The field doesn't have to be on the form, it's just used in the template condition.



rgds



Xavier


View solution in original post

12 REPLIES 12

Jay_Ford
Kilo Guru

Have you tried using email client templates?



Enabling the Email Client - ServiceNow Wiki



Section 5.2


Yes, but then I've another issue : as I need an Icon near the assigned to field and another Icon near the technician, how can I do the distinction between these 2 different mail template...



The only way I see to do this is to fill the fields from the url



but thanks for the answer


johnram
ServiceNow Employee
ServiceNow Employee

The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here: Email Setup



Visit http://docs.servicenow.com for the latest product documentation


brumiou
Mega Guru

Hi,



maybe it can help somebody, but I've managed to do it.


I've created a field called u_client_mail_type as a choice field with different velues in it : assigned_to, technical_correspondant, user.


For each value I've created a client mail template with this field and value in the condition.



And in the ui macro, I simply call the popupOpenEmailClient like that :





popupOpenEmailClient("email_client.do?sysparm_table=incident&sysparm_sys_id="+id+"&sysparm_target=incident&sys_target=incident&sys_uniqueValue="+id+"&sys_row=0&sysparm_encoded_record=&incident.u_client_mail_type=assigned_to&sysparm_stack=no");



the important part is the incident.u_client_mail_type=assigned_to at the end of the url, to select the template I need.



The field doesn't have to be on the form, it's just used in the template condition.



rgds



Xavier