- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2020 07:47 AM
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.
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2020 05:14 AM
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&sysparm_sys_id=" + sys_id + "&sysparm_target=incident&sys_target=incident&sys_uniqueValue=" + sys_id + "&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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2020 10:35 PM
Hi,
You can use URL for email generation as "https://<instance_name>.service-now.com/email_client.do?sysparm_table=<table_name>&sysparm_sys_id=<s..."
In macro you will need to fetch current record table name and sys_id.
Please mark reply as Helpful/Correct, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2020 12:26 AM
Sorry i cant open the link.
I almost got it, just one thing is missing:
<?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 mail = current.u_mail_1.getDisplayValue(); // Not working
var url = new GlideURL("email_client.do?sysparm_table=incident&sysparm_sys_id=" + sys_id + "&sysparm_target=incident&sys_target=incident&sys_uniqueValue=" + sys_id + "&sys_row=0&sysparm_encoded_record=&incident.u_mail_1=" + mail + "&sysparm_domain_restore=false&sysparm_stack=no");
</g2:evaluate>
<a href="$[url]" target="_blank" class="btn btn-default icon-mail"></a>
</j:jelly>
the var mail is not working. The code without the var mail is working. But then the mail client template "antwortmail" is always opened (because its in the URL)
<?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, mail;
table = RP.getParameterValue('jvar_ref_table');
sys_id = current.sys_id;
var url = new GlideURL("email_client.do?sysparm_table=incident&sysparm_sys_id=" + sys_id + "&sysparm_target=incident&sys_target=incident&sys_uniqueValue=" + sys_id + "&sys_row=0&sysparm_encoded_record=&incident.u_mail_1=antwortmail&sysparm_domain_restore=false&sysparm_stack=no");
</g2:evaluate>
<a href="$[url]" target="_blank" class="btn btn-default icon-mail"></a>
</j:jelly>
I created a column "u_mail_1 " with type choice at the incident table. How can i display the current value for the URL?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2020 01:19 AM
Hi,
You can get display value of u_mail_1 by using GlideRecord as below.
var table, sys_id;
table = RP.getParameterValue('jvar_ref_table');
sys_id = current.sys_id;
var gr = new GlideRecord('incident');
gr.get('sys_id');
var mail = gr.u_mail_1.getDisplayValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2020 01:43 AM
<?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, mail;
table = RP.getParameterValue('jvar_ref_table');
sys_id = current.sys_id;
var gr = new GlideRecord('incident');
gr.get('sys_id');
var mail = gr.u_mail_1.getDisplayValue();
var url = new GlideURL("email_client.do?sysparm_table=incident&sysparm_sys_id=" + sys_id + "&sysparm_target=incident&sys_target=incident&sys_uniqueValue=" + sys_id + "&sys_row=0&sysparm_encoded_record=&incident.u_mail_1=" + mail + "&sysparm_domain_restore=false&sysparm_stack=no");
</g2:evaluate>
<a href="$[url]" target="_blank" class="btn btn-default icon-mail"></a>
</j:jelly>
This way? But still not working. And in the URL is missing the part "incident.u_mail1="