UI Macro open Email Client

Maki
Tera Expert

Hello again,

i need a little help with the email client.

I found some threads like (1 / 2) but i dont get it 100% working. 

I got a column in incident "u_mail" with some choices. Different Email Client Templates with a condition to the u_mail. 
If i choose "Antwortmail" for example, click on the default email button (more Options) the Email Template "Antwortmail" opens. So this is working fine.

find_real_file.png

I copied a macro, but missing is the correct URL (??? in macro) to open the Email Client.

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


   <a href="???" target="_blank" class="btn btn-default icon-mail"></a>


</j:jelly>

Or can i just copy the function from the default E-Mail Button (more options menue) to my button? 

1 ACCEPTED SOLUTION

Hi,

 

Please refer below to fulfill requirement:

------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<g2:evaluate>

var table, sys_id;
table = RP.getParameterValue('jvar_ref_table');
sys_id = current.sys_id;


var url1="/email_client.do?sysparm_table=incident&amp;sysparm_sys_id=" + sys_id + "&amp;sysparm_target=incident&amp;sys_target=incident&amp;sys_uniqueValue=" + sys_id + "&amp;incident.u_mail_1=";
</g2:evaluate>

<a href="$[url1]" id="temp_link" target="_blank" class="btn btn-default icon-mail" onclick="test(this)">AA</a>
<input type="hidden" id="url_value" value="$[url1]"/>

<script>
function test(a){
var url = document.getElementById("url_value").value;
a.href=url+g_form.getValue("u_mail_1");
}
</script>

</j:jelly>

--------------------------------------------------------------------

 

Please mark reply as Helpful/Correct, if applicable. Thanks!

View solution in original post

17 REPLIES 17

Hi,

 

Can you please tell me what is use case here to use incident.u_mail_1 in url?

Are you able to get value of u_mail_1 field?

Thanks.

Use Case:

I got a choice field with 3 values. For each value i have an email client template. 

when i select "antwortmail" and click the default email client button (under more option) everything is working fine. 

Now i want to create a custom email button next to the choice field via ui macro.

find_real_file.png

But i have to tell the email client (via url) which email client template is to use. 

(for example, condition for email client template antwortmail is "u_mail_1 = antwortmail"

Hi,

 

Okay, so you want to decide email template based on value in u_mail_1 field. 

You must have created separate email client templates for different values in mail1 field. You need to add condition to those email templates itself as  Mail1=<xyz>.

You do not need to add mail1 parameter in url.

 

Hope this resolves your issue/question.

If it helps, Please mark  Correct and 👍 Helpful.

 

Thanks.

Okay, so you want to decide email template based on value in u_mail_1 field. 

yes exactly. 

You must have created separate email client templates for different values in mail1 field. You need to add condition to those email templates itself as  Mail1=<xyz>.

I already have 3 email templates based on the value u_mail_1. 

You do not need to add mail1 parameter in url.

yes, missing thing is to parse the value to the URL.

But i dont get the value (choice?)

06.06.2020 12:19
Information	gr._u_mail_1: undefined
		
06.06.2020 12:19
Information	gr.u_mail_1.getDisplayValue():

Hi,

If you put condition in email client template itself, you don't need to pass it in url.

System takes email template as per setup automatically. So you dont need to access it in ui page as well. Hope that helps.

find_real_file.png

Thanks.