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

Harsh Vardhan
Giga Patron

use open() like below. give a try. 

 

var w = getTopWindow();

w.open('sip:'+emailId, "_top"); // or you can change param to _self

Servicenow10
Kilo Guru

@Harshvardhan 

hi,

i used your approach and it gave same result....

my requirement is to show teams  icon next to caller_id field on incident form for that user...

so when someone wants to communicate to that user by clicking on the icon it will opwn teams chat pop up.

 

now what i did:

i have added an attribute in caller_id field through configure dictionary.

also, created one ui macro the above code is above

and i have made my default sip protocol as teams 

 

however, am not sure its a script issue or something not related to script.

 

thanks in advance!!

 

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>

hi harshavardhan,

the above code which you shared is in one of the links which has been shared by ankur in below post.

 

now i will use the above link which you shared and update you in sometime...

thankyou so much very helpful