UI macro redirect to teams chat window is not working for NEW TEAMS

anataraj
Tera Contributor

Hi All,

I have existing UI Macro Script to redirect MS teams chat window and its working fine with Classic Teams but recently we have upgraded to NEW MS TEAMS. the below existing script was not working for NEW MS TEAMS. Could you please help me on this?

<?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="TeamsChat.png" width="25" height="30" onClick="InvokeChat('${ref}');" tabindex = "0"></img></a>

<script>
function InvokeChat(reference)
{
//alert("value of ref is "+reference);
var refVal = reference.split(".");
var fieldName = refVal[1];
var sysID = g_form.getValue(fieldName);
//alert("sys id "+sysID);
var emailID= '';
var sd = "short description of the incident";

var gr = new GlideRecord("sys_user");
if(gr.get(sysID))
{
emailID = gr.email.toString();

}

if(emailID)
{

//open('sip:'+emailID,'_top','sd');
    var firstname = g_form.getReference('caller_id').first_name;
var nm = g_form.getValue('number');
var sd = g_form.getValue('short_description');
var url = 'https://teams.microsoft.com/l/chat/0/0?users=' + emailID + '&amp;amp;message=Hi ' + firstname + ', this is regarding your Incident ' + nm + ': ' + sd + ' ';
var w = getTopWindow();


w.open(url);
}
else
{
alert("hey you not have proper mail ID");
}

}
</script>

</j:jelly>



Thanks & Regards 
Nataraj




4 REPLIES 4

palanikumar
Mega Sage

I don't see any issue in this. Try changing the URL with these two and see any one of them fixes your issue:

 

var url = 'https://teams.microsoft.com/l/chat/0/0?users=' + emailID + '&amp;message=Hi ' + firstname + ', this is regarding your Incident ' + nm + ': ' + sd + ' ';

 

or

 

var url = 'https://teams.microsoft.com/l/chat/0/0?users=' + emailID + '&message=Hi ' + firstname + ', this is regarding your Incident ' + nm + ': ' + sd + ' ';

 

Thank you,
Palani

@palanikumar  
thanks for your suggestion, But its not working! still same issue was happing

PRASHANTH  K CH
Tera Expert
Use this anataraj
<?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 class="btn-default;" id="${jvar_n}" onclick="invokeChat1('${ref}');">
              <img src="teams.png" width="30"  title="Teams Chat" alt="${gs.getMessage('Click to open Teams chat')}" />
</a>
<script>
function invokeChat1(reference) {

var firstname = g_form.getReference('caller_id').first_name;
var user = g_form.getReference('caller_id').email;
var subject = '&amp;amp;message=Hi ' + firstname + ', I am contacting you regarding your Incident ' + g_form.getValue('number') + ': ' + g_form.getValue('short_description');

var w = getTopWindow();
var url = prefix + user + subject;
w.open(url);
}
</script></j:jelly>

Okey Okoroma
Tera Contributor

Not sure if anyone got an answer but this worked for me

 

<?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="teams_chat_${jvar_guid}:${ref}"/>
<a id="${jvar_n}" 
   class="ref-button btn btn-default btn-ref" 
   style="padding:5px 6px 7px; visibility:hidden;" 
   onclick="invokeChat('${ref}');">
    <img border="0" 
         src="Microsoft_Teams_16x16.png" 
         title="Teams Chat" 
         alt="${gs.getMessage('Click to open Teams chat')}" />
</a>
	<script>
	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;
		var subject = '&amp;amp;message=Hi ' + firstname + ', this is regarding your Incident ' + g_form.getValue('number') + ': ' + g_form.getValue('short_description');

		var w = getTopWindow();
		var url = prefix + user + subject;
		w.open(url);
		
	}

	// show/hide button based on field value
	function decorationShow(element, original, changed, loading) {
  		var visibility = 'hidden';
		if (changed.length > 0) {
			var parentTr = gel('element.' + element.id);
			if (!(parentTr $[AMP]$[AMP] parentTr.style.visibility == 'hidden'))
				visibility = 'visible';
  		}

  		var e = gel('${jvar_n}');
  		e.style.visibility = visibility;
}

	// handle the onchange event
	var n = '${ref}'.replace(/\./g, '_');
	var h = new GlideEventHandler('onChange_' + n, decorationShow, '${ref}');
	g_event_handlers.push(h);
	</script>
</j:jelly>