ui macro not working properly

Servicenow10
Kilo Guru

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!!

1 ACCEPTED SOLUTION

adding one blog here. 

 

Teams Integration with Incidents - Start new chat from Incident form using Microsoft Deep Link and U...

 

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>

View solution in original post

7 REPLIES 7

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.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Here is an article explaining the same in detail

please go through these and they should help you

Service-Now – Microsoft Teams Integration

https://community.servicenow.com/community?id=community_question&sys_id=6743c4a0dbec58105ed4a851ca96...

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Servicenow10
Kilo Guru

hi @Ankur Bawiskar ,

 

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 🙂