email client template script for button click

Barathk
Tera Contributor

Hi,
i have created an email client template , should be populate after click the complete supplier selection in the negotiation  form.
please suggest.

Barathk_0-1704966248549.png

 

2 REPLIES 2

Abbas_5
Tera Sage
Tera Sage

Hello @Barathk,

similar kind of requirement, please refer to the below link:
https://www.servicenow.com/community/developer-forum/email-client-template-calling-through-ui-action...

 

If it is helpful, please mark it as helpful and accept the correct solution.

Thanks & Regards,
Abbas Shaik

HerbertW
Tera Contributor

As i've been hunting a ghost for the past weeks, i just want to add that all those posts from the past talk about directly calling an email client template by passing in the sys_id of the template.
This does NOT work (anymore).
servicenow decides which template to call and you have no influence over that.
If you need a specific template to be called, you need to get creative, for example setting a (hidden) field value temporarely, like so:

function openEmailClient()
{
    var state = g_form.getValue('u_supplier_state'); // save the current value
    g_form.setValue('u_supplier_state','send to supplier'); // change it to something unique so you can build the email client template condition
    emailClientOpenPop('incident_task'); // open the email client and let servicenow find your template
    g_form.setValue('u_supplier_state',state); // reset, so servicenow finds the default template for all other calls of the email client on that table
}