The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Chavan AP
Giga Guru

Service-Now – Microsoft Teams

 

Follow below steps to integrate Snow with Teams for popup chat :

 

  1. Add team icon image to images. 

 find_real_file.png

find_real_file.png

 

  1. Now we must call UI macros on Caller ID field:

find_real_file.png

Add popup_chat in Caller ID field attribute as shown below:

 find_real_file.png

 

  1. Now create a popup_chat UI macro

 find_real_file.png

 

 find_real_file.png

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:

 find_real_file.png

  

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

 

Comments
AbhishekGardade
Mega Sage
Mega Sage

Nice Post Ajay!!!!!

Chavan AP
Giga Guru

thank you Abhishek

User285701
Kilo Contributor

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?

Shushan Poojar1
Giga Contributor

You can also use this in your URL:

var url = 'im:' + email;
var w = getTopWindow();
w.open(url);

 

Chavan AP
Giga Guru

Oh i didn't know about that , thank you Shushan

Puja Kumari1
Tera Contributor

Helpful

Shushan Poojar1
Giga Contributor

You're welcome Ajay

Shushan Poojar1
Giga Contributor

Right Click on Caller Id Field - > Configure Dictionary - > Attributes - > Paste Your UI Macro name with ; seperated.

Thanks!

NK32
Kilo Expert

Thank this worked for me 🙂

siva_
Giga Guru

Do you have any deeplink handy that can be used for webex teams?

Thanks,

Siva

Tushar Walveka2
Giga Guru

Well Written. 

User285701
Kilo Contributor

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

User285701
Kilo Contributor

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?

Chavan AP
Giga Guru

Hi Sifisc,

 

This is possible using integration Hub,

Please refer link below:

https://community.servicenow.com/community?id=community_blog&sys_id=3ca3a969db62bfc0d82ffb2439961962

sweetymiriyala
Giga Contributor

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

Chavan AP
Giga Guru

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;

 

 

 

Chavan AP
Giga Guru

will please share me SS of ur filed dictionary attribute

Sree Gorantla
Giga Contributor

Hi Ajay,

Will this integration copy the chat details into ticket activity section?

Santhosh40
Giga Expert

Awesome...

Thanks Ajay. It's working like a charm...

Santhosh40
Giga Expert

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?

Kim Sullivan
Mega Guru

Works great!  Awesome job!

arnabbhaumik
Tera Contributor

Thanks @Ajay Chavan . Worked for me. However if i want to add a message when opening the teams chat like "Hi! How are you? " how can i attach that in the url itself as "&message" is not working in xml. 

Kim Sullivan
Mega Guru

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!

SKum
Kilo Guru

Did you find the solution ?

 

Thanks 

Kim Sullivan
Mega Guru

Ditto - we'd like to attach the ticket number and short description.

Kim Sullivan
Mega Guru

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;amp;message=' + nm + ': ' + sd + ' - ';

arnabbhaumik
Tera Contributor

yeah thanks @Kim Sullivan . It alsow worked for me. But I think for testing if you opne the same users chat from same incident the messages keeps adding the no of times you open it. But in real life it will not happen. So works fine actually.

arnabbhaumik
Tera Contributor

try to do glideRecord from request table via the task or RITM number instead of directly dot walk.

Rj27
Mega Guru

@Kim Sullivan did it work for you on ritm table?

Kim Sullivan
Mega Guru

No -- I worked on it for a couple of hours, then gave up.  Would love to hear if anyone else got it working!

Deyvisson Lobat
Kilo Explorer

Worked for me.

Try add ref_contributions=popup_chat instead just popup_chat in the attribute. 

Rj27
Mega Guru

still not working for me on ritm form

Rj27
Mega Guru

This is working for me. Thanks @Deyvisson Lobato 

Kim Sullivan
Mega Guru

No - it didn't work for me.  My Requested for field is dot walked from sc_request.

Sumanth Now
Tera Expert

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

PaulSylo
Mega Sage
Mega Sage

Can you pls explain me on this , pls

Servicenow10
Kilo Guru

hi @AjayChavan ,

 

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 🙂 

 

Brian S5
Giga Guru

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 ? 

ABSG-001
Tera Expert

Hi @Kim Sullivan , Did you manage to get this working?

ABSG-001
Tera Expert

Hi @Sumanth Now , did this work for REQUESTED ITEM/CATALOG TASK?

Kim Sullivan
Mega Guru

No, never did. I think I'll have to create a requested_for field on sc_req_item and sc_task to use it.

Sumanth Now
Tera Expert

Hi @Charles , yes it worked on Requested Items too.

ABSG-001
Tera Expert

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?

 

Ritu K
Kilo Explorer

Thanks for sharing

Travis Rider
Kilo Contributor

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;

Josh Petrick
Giga Guru

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");
}

Josh Petrick
Giga Guru

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.

Kim Sullivan
Mega Guru

@Josh Petrick  - this worked for me.  Thanks!

Chris Bell
Giga Explorer

Question? Are the conversations saved in the ticket when the chat is closed out?

Nicholas Diak
Kilo Explorer

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. 

Version history
Last update:
‎10-15-2019 12:46 AM
Updated by: