UI Macro - Open teams and start populating message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2020 10:12 AM
Hi All,
I've added a UI macro with a Microsoft Teams icon next to our assigned_to field to open a teams chat for that user. I've been asked if when it opens it could start the chat message with:
'Hi' + assigned_to.first_name + 'this is in regards to ticket' + number + short_description.
Has anyone achieved this, we are using the desktop teams app.
current ui macro is:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />
<j:set var="jvar_n" value="show_incidents_${jvar_guid}:${ref}"/>
<a id="${jvar_n}"
onclick="invokeChat('${ref}');"
name="${jvar_n}"
onmouseout="lockPopup(event)"
tabindex="0"
>
<img border="0" src="teams.png" width="28" height="28" title="${gs.getMessage('Open Teams chat')}" />
</a>
<script>
function invokeChat(reference) {
var s = reference.split('.');
var tableName = s[0];
var referenceField = s[1];
var v = g_form.getValue(referenceField);
var email;
var gr = new GlideRecord('sys_user');
if (gr.get(v)) {
email = gr.email;
}
var url = 'sip:'+email;
//var w = getTopWindow();
//w.open(url);
window.location = url;
}
</script>
</j:jelly>
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2020 11:47 AM
Hi.
I don't know if you ever achieved what you were trying to do - but I managed to get it to work 😉
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_guid" expression="gs.generateGUID(this);" />
<j:set var="jvar_n" value="show_incidents_${jvar_guid}:${ref}"/>
<a id="${jvar_n}"
onChange="onChange('${ref}');"
onclick="invokeChat('${ref}');"
name="${jvar_n}"
onmouseout="lockPopup(event)"
tabindex="0"
>
<img border="0" src="Microsoft_Teams_16x16.png" width="28" height="28" title="${gs.getMessage('Open Teams chat')}" />
</a>
<script>
function onChange(element, original, changed, loading) {
var visibility = 'visible';
var sysID = g_form.getValue('assigned_to');
if (!sysID)
visibility = 'hidden';
var e = gel('${jvar_n}');
e.style.visibility= visibility;
}
function invokeChat(reference) {
var number = g_form.getValue('number');
var short_desc = g_form.getValue('short_description');
var s = reference.split('.');
var tableName = s[0];
var referenceField = s[1];
var v = g_form.getValue(referenceField);
var email;
var gr = new GlideRecord('sys_user');
if (gr.get(v)) {
email = gr.email;
firstName = gr.first_name
}
var url = 'msteams:/l/chat/0/0?users=' + email + '&amp;message=Hi ' + firstName + ', this is regarding ticket: ' + number + ' - ' + short_desc;
var w = getTopWindow();
w.open(url);
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2020 01:21 AM
didn't manage it in the end and as it wasn't critical we just left it using the ability to just open a chat. I will give you script a try.
Thanks for coming back on this though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 04:25 PM
Hey...
Hope you are doing well. Thanks for the jelly code. Would you know if there is way for this to work in agent workspace or service-operations workspace?
I know for a fact that UI macro is not supported on agent workspace. Is there anyother way to make this work in workspace.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 08:26 AM
Hi,
Great script, but a few things are causing me issues.
First: When I turn on the UI MAcro, when I choose Catecory (any), non of Subcategories appears.
Second: when I choose Category, icon disappears
Any ide why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2021 03:33 PM
Hi
I have used your code and it is working fine . thanks for your effort.
but one more thing just i want to send INC number as a inc link.
would be great if you have this code also or concept to send inc number as a link in caller's teams message.
like
Hi Caller, this is regarding ticket: INCxxxxxx - Other Issues - ServiceNow
thank in advance