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

BK9
Tera Contributor

Hi Xavier,



I've attempted this, but I can't get the url to select my email client template. I put the conditions in the email client template, but it isn't being selected. Any help would be great. Below is the url that I'm using:



email_client.do?sysparm_table=sc_request&sysparm_sys_id="+sysId+"&sysparm_target=sc_request&sys_target=sc_request&sys_uniqueValue="+sysId+"&sys_row=0&sc_request.u_client_mail_type=assigned_to&sysparm_stack=no



Thanks.



Hi Brent,



in my system, I had to replace the '&' in the url by '&'.


Let's try that first



rgds



Xavier


Hi Xavier,



I have a similar requirement and I am trying to implement what you mentioned. I have a custom table and I have created a field called UI Action Type and have that mentioned in my client template as a condition. The following code opens the email template however it doesn't pick the template. Could you direct me in the correct direction.



popupOpenEmailClient("email_client.do?sysparm_target=u_work_order&sysparm_table=u_work_order&u_work_order.u_ui_action_type=SAN&sysparm_sys_id=" + id + "&sys_uniqueValue=" + id);



Thanks,


Urmilla


kreddyT
Mega Contributor

Were you able to change the "ReplyTo" in client template?


i need to set it to "assigned_to" user on my form but Replyto takes default system's email address.


I tried using email.setReplyto(); in mail_script but it didnt work.



Do you know a way to override the default replyto value in client template?




Thank you


Hi,


are you sure it's in a email client template?


Then you have a field "Reply to".


Maybe it's just not displayed on your form.


I use the current logged user for this field, so it's set to : javascript:gs.getUserDisplayName() + "<" + gs.getUser().getEmail() + ">"



rgds



Xavier