- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2020 12:09 PM
hi all,
below is the code of my UI Macro and i can only see image icon but i whenever i click on that icon it doesn't open the teams app am not getting where am i wrong.
also i have set by default app protocol for chat as teams still its not working
can anybody help me with this issue:
<?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> <img src="teams.png" width="25%" height="25%" onclick ="userWindow('${ref}')" tabindex ="0"></img></a>
<script>
function userWindow(reference){//incident.caller_id
var refVal = reference.split('.');
var fieldName = refVal[1];
var emailId;
var sysID = g_form.getValue(fieldName);
var user = new GlideRecord('sys_user');
if(user.get(sysID)){
emailId = user.email.toString();
}
if(emailId){
open('sip:'+emailId, '_top');
}
else{
g_form.addErrorMessage('User doesn't have email in ServiceNow');
}
}
</script>
</j:jelly>
thanks in advance!!
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2020 12:06 AM
adding one blog here.
can you add some alert in your script to check the output of your url.
also can you add sample user email which you are trying to split here ?
eg:
<?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 class="btn-default;" id="${jvar_n}" onclick="invokeChat('${ref}');">
<img src="teams.png" width="30" title="Popup Teams" alt="${gs.getMessage('Click to 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 = 'https://teams.microsoft.com/l/chat/0/0?users='+email;
alert(url);
var w = getTopWindow();
w.open(url);
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2020 09:38 AM
Hi Harsh, thanks for this wonderful video. I was able to implement this on my instance with incidents however when I tried to implement with request, I had some difficulties. When I click on the UI macro icon on the RITM and SCTASK forms, it doesn't launch but it launches fine on the REQ form. Any guidance on this would be very much appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2020 07:59 AM
Hi,
Here is an article explaining the same in detail
please go through these and they should help you
Service-Now – Microsoft Teams Integration
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2020 10:44 PM
hi
the above post are very helpful and am using it for my current scenario.
however, the only difference is in my organization we have email as name.@gmail.com
but for teams id we use userid@gmail.com......so how to modify this in given code and get desired o/p.
below is the code .....please highlight your changes:
<?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 class="btn-default;" id="${jvar_n}" onclick="invokeChat('${ref}');">
<img src="teams.png" width="30" title="Popup Teams" alt="${gs.getMessage('Click to 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 = 'https://teams.microsoft.com/l/chat/0/0?users='+email;
var w = getTopWindow();
w.open(url);
}
</script>
</j:jelly>
thanks in advance 🙂