Teams UI Macro Working Not properly

siva44
Tera Contributor

I have created UI Macro for teams integration it is working fine but whenever click the web teams app then it is showing message twice and whenever click the teams app then working fine

UI Macro 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">
<a class="btn-default;" id="${jvar_n}" onclick="invokeChat('${ref}');">
              <img src="teams.png" width="30"  title="Teams Chat" alt="${gs.getMessage('Click to open Teams chat')}" />
</a>
<script>
function invokeChat(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 + ', 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);
}
</script></j:jelly>
13 REPLIES 13

try this once and let me know:

var subject = 'message=Hi ' + encodeURIComponent(firstname) +
', this is regarding your Incident ' + encodeURIComponent(g_form.getValue('number')) +
': ' + encodeURIComponent(g_form.getValue('short_description'));

Now not showing any message in teams chat

please let me know - are you processing string in the URL or the form submission context?

 

also try once with :

var subject = 'message=Hi ' + firstname + ', this is regarding your Incident ' + g_form.getValue('number') + ': ' + g_form.getValue('short_description');

 

 Not working ,pls check below code:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide">
 
<a class="btn-default" id="${jvar_n}" onclick="invokeChat('${ref}'); return false;">
<img src="10starton.png" width="30" title="Teams Chat" alt="${gs.getMessage('Click to open Teams chat')}" />
</a>
 
<script>
var timeout;
function invokeChat(reference) {
    if(timeout){
        clearTimeout(timeout);
    }
    timeout=setTimeout(function(){
 
g_form.getReference('caller_id', function(caller) {
var firstname = caller.first_name;
var user = caller.email;
 
//var subject = '&amp;amp;message=Hi ' + encodeURIComponent(firstname) +
//', this is regarding your Incident ' + encodeURIComponent(g_form.getValue('number')) +
//': ' + encodeURIComponent(g_form.getValue('short_description'));
var subject = 'message=Hi ' + firstname + ', this is regarding your Incident ' + g_form.getValue('number') + ': ' + g_form.getValue('short_description');
 
var url = prefix+user+subject;
var w = getTopWindow();
w.open(url);
});
    },100);
}
</script>
</j:jelly>