The Now Platform® Washington DC release is live. Watch now!
on 10-15-2019 12:46 AM
Service-Now – Microsoft Teams
Follow below steps to integrate Snow with Teams for popup chat :
Add popup_chat in Caller ID field attribute as shown below:
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
Nice Post Ajay!!!!!
thank you Abhishek
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?
You can also use this in your URL:
var url = 'im:' + email;
var w = getTopWindow();
w.open(url);
Oh i didn't know about that , thank you Shushan
Helpful
You're welcome Ajay
Right Click on Caller Id Field - > Configure Dictionary - > Attributes - > Paste Your UI Macro name with ; seperated.
Thanks!
Thank this worked for me 🙂
Do you have any deeplink handy that can be used for webex teams?
Thanks,
Siva
Well Written.
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
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?
Hi Sifisc,
This is possible using integration Hub,
Please refer link below:
https://community.servicenow.com/community?id=community_blog&sys_id=3ca3a969db62bfc0d82ffb2439961962
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
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;
will please share me SS of ur filed dictionary attribute
Hi Ajay,
Will this integration copy the chat details into ticket activity section?
Awesome...
Thanks Ajay. It's working like a charm...
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?
Works great! Awesome job!
Thanks
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!
Did you find the solution ?
Thanks
Ditto - we'd like to attach the ticket number and short description.
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 + ' - ';
yeah thanks
try to do glideRecord from request table via the task or RITM number instead of directly dot walk.
No -- I worked on it for a couple of hours, then gave up. Would love to hear if anyone else got it working!
Worked for me.
Try add ref_contributions=popup_chat instead just popup_chat in the attribute.
still not working for me on ritm form
This is working for me. Thanks
No - it didn't work for me. My Requested for field is dot walked from sc_request.
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
Can you pls explain me on this , pls
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 🙂
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 ?
Hi
Hi
No, never did. I think I'll have to create a requested_for field on sc_req_item and sc_task to use it.
Hi
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?
Thanks for sharing
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;
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");
}
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.
Question? Are the conversations saved in the ticket when the chat is closed out?
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.