Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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,

 

I am able to get value of u_mail_1. Could you please add log in evaluation script to check mail1 value. Try gr.getDisplayValue("u_mail_1"),  gr.u_mail_1, gr.getValue("u_mail_1").

You do not need separate gilderecord query in order get this field value.

 

Thanks.

can you please give me a help with the log 🙂

Is this correct? 

gs.log("display value: " + gr.getDisplayValue("u_mail_1");
gs.log("gr mail value: " + gr._u_mail_1);
gs.log("mail value: " + mail);

Try this:


gs.log("current mail value: " + current.u_mail_1);
gs.log("mail value: " + current.getValue("u_mail_1"));

gs.log("display value: " + current.getDisplayValue("u_mail_1"));