- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 10-15-2019 12:46 AM
Service-Now – Microsoft Teams
Follow below steps to integrate Snow with Teams for popup chat :
- Add team icon image to images.
- Now we must call UI macros on Caller ID field:
Add popup_chat in Caller ID field attribute as shown below:
- Now create a popup_chat UI macro
Now here is the important part which is UI Script:
<?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>
In this code there is Teams Deeplink given by Teams that we must include.
https://teams.microsoft.com/l/chat/0/0?users='+email;
That’s all guys you will see Teams Icon on Caller ID field as below:
Now whenever you will select the Caller ID and click on Teams icon it will redirect to teams chat for selected user .
Please like , share, subscribe to this article.
In case of improvements please suggest me in comments.
Regards,
Ajay Chavan
+91-9769949577
India
- 23,326 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Nice Post Ajay!!!!!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
thank you Abhishek
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
hi Ajay, tanks for the information I am stick on step 2. Please show me in details, how do i call ui macros in caller id field?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
You can also use this in your URL:
var url = 'im:' + email;
var w = getTopWindow();
w.open(url);
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Oh i didn't know about that , thank you Shushan
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Helpful
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
You're welcome Ajay
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Right Click on Caller Id Field - > Configure Dictionary - > Attributes - > Paste Your UI Macro name with ; seperated.
Thanks!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thank this worked for me 🙂

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Do you have any deeplink handy that can be used for webex teams?
Thanks,
Siva

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Well Written.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I have created as instructed it works just not creating a new chat, I am not sure if its permissions on my teams app. It just open teams with my current chat
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
hi Ajay
I successfully created the SNOW and Teams integration as per your guidance and All works fine. Please advise how I can make the heading of the chat to be the request number and also make the chat messages as well as attachments to be available on the incident on SNOW?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Sifisc,
This is possible using integration Hub,
Please refer link below:
https://community.servicenow.com/community?id=community_blog&sys_id=3ca3a969db62bfc0d82ffb2439961962
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Ajay,
I wanna use this feature in service portal . I couldnt place this macro anywhere as Portal doesn't support UI Macros. Could you please suggest me how can I use this Portal in a more effective way?
Thanks in Advance
Regards,
Sweety
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi,
You can create a custom widget , where you can an ability like button or link with below url:
'https://teams.microsoft.com/l/chat/0/0?users='+email;
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
will please share me SS of ur filed dictionary attribute

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Ajay,
Will this integration copy the chat details into ticket activity section?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Awesome...
Thanks Ajay. It's working like a charm...
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Ajay..
Thanks for the post. it working fine in my Personal DEV instance.
But, after implementing into my work instance, It's not working. I am unable to find TEAMS ICON.
Can you please help me to debug?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Works great! Awesome job!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Side note -- we're running Orlando in our DEV instance. This works great for the TASK table, using "task_for" and "caller_id" on INCIDENT. No luck with REQUEST/REQUESTED ITEM/CATALOG TASK. Something off about trying to dot walk and get the "requested_for" off of the REQUEST table.
If anyone got this working in Orlando, please ping me! Thanks!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Did you find the solution ?
Thanks
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Ditto - we'd like to attach the ticket number and short description.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Got it work with this:
var nm = g_form.getValue('number');
var sd = g_form.getValue('short_description');
var url = 'https://teams.microsoft.com/l/chat/0/0?users=' + email + '&amp;message=' + nm + ': ' + sd + ' - ';
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
yeah thanks
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
try to do glideRecord from request table via the task or RITM number instead of directly dot walk.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
No -- I worked on it for a couple of hours, then gave up. Would love to hear if anyone else got it working!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Worked for me.
Try add ref_contributions=popup_chat instead just popup_chat in the attribute.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
still not working for me on ritm form
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This is working for me. Thanks
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
No - it didn't work for me. My Requested for field is dot walked from sc_request.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I have tried in Orlando and it worked on sc_request table.
Instead of adding the value directly to the Attributes field, you need to create a new attribute under the related lists 'Attributes'.
Please find the attached screenshot for reference.
Please Mark ✅ Correct and/or mark 👍 Helpful as applicable.
Thanks
Sumanth
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Can you pls explain me on this , pls
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
hi
this post is very helpful and am using it for my current scenarion.
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 your code and get desired o/p.
thanks in advance 🙂
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Is there a way to only show this if the person has a teams account, or add a message that the contact selected doesn't have a teams account ?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
No, never did. I think I'll have to create a requested_for field on sc_req_item and sc_task to use it.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Mine is displaying a weird behavior, when I click on the MS Teams UI Macro. it redirects me to MS Teams however it doesn't direct me to the specified user.
Any advice? Did you modified the code, if so can you share?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks for sharing
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Quick question. We have a custom field we added to our Incidents table labeled Contact person (u_contact_person). When I add the UI Macros for both of these fields (Caller & Contact Person) the contact person UI will override the caller macros. I have added the Attributes to both fields respectively. What have I missed?
teams_chat_caller
function invokeChat(reference) {
var prefix = 'msteams:/l/chat/0/0?users=';
var firstname = g_form.getReference('caller_id').first_name;
var user = g_form.getReference('caller_id').email;
teams_chat_contact
function invokeChat(reference) {
var prefix = 'msteams:/l/chat/0/0?users=';
var firstname = g_form.getReference('u_contact_person').first_name;
var user = g_form.getReference('u_contact_person').email;
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I was able to get it working on dot-walked fields, but I had to create a copy of Macro, use a different function name, and I used an if/else statement in the macro so it would work on the requested for field no matter which form I was on. We have a custom u_requested_for field, so your script may be a little different, but here's what I used:
function openLink2(ref) {
var tck = g_form.getValue('number');
if(tck.indexOf('TASK') >= 0){
var email = g_form.getReference('request_item.u_requested_for').email;
} else {
var email = g_form.getReference(ref.split('.')[1]).email;
}
var url = 'msteams:/l/chat/0/0?users=';
url += email;
url += '$[AMP]topicname=Chat';
window.open(url, "_blank");
}
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Try changing the name of one of the functions, so they are unique. Just change one to "invokeChat2", and make sure you change the references to it in the UI Macro as well.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Question? Are the conversations saved in the ticket when the chat is closed out?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
rename your invokeChat variables in each macro that is on the same page. invokeChat1 and invokeChat2 etc. Browser is just picking one to load over the other.