Custom UI Action for opening Teams chats from Incident Form/SOW

PiotrI
Tera Expert

Hello Community,

 

I'm setting up a custom UI Action button for opening Teams Chat directly from incident form and/or Service Operation Workspace . The logic behind is pretty simple, it just takes the email from the user on the form (caller.id) and just chain it with the teams URL https://teams.microsoft.com/l/chat/0/0?users=, nothing to fancy. Of course for the Workspace it's a bit more complicated, I had to use a script include to get the email. I did that on my PDI and it was working perfectly fine. But when I moved to one of our internal instances, I replicated the developemnt and I got to a point where the UI Actions are set up, it does not work sadly.

 

So I did some troubleshooting added additional steps to the code to check if it is running properly and what might be the issue, because on our internal instance, when you click on that button it does nothing. I mean if I add debugging steps hey are being picked up and executed but the teams url is not openining. First I thought it's becuase I was doing that in incognito window but I wrote a HTML page with similar button and hardcoded the users email and it works perfectly fine. 

 

That makes me think that on SN level something is blocking that external URLs from being opened, I went through the documentation and checked in couple of places but I wasn't able to identify what's wrong. So I come to you, honorable people, maybe you tried something like that, and had better luck with making this work.

 

If any more details is needed, let me know !

1 ACCEPTED SOLUTION

PiotrI
Tera Expert

Found the solution:

 

We used g_navigation 

function openTeamsChat() {
   
    var userEmail = g_form.getReference('caller_id', function(user) {
        if (user && user.email) {
            var teamsURL = 'https://teams.microsoft.com/l/chat/0/0?users=';
            var userEmail = encodeURIComponent(user.email.toString());
            var sUrl = teamsURL+userEmail.toString();
            g_navigation.openPopup(sUrl, 'Teams call', 'resizable,scrollbars,status', true);  //Opening actual window for Teams

        } else {
            alert('No email found for this user.');
        }
    });
}

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@PiotrI 

please share what have you configured so far?

what's the difference when you moved the code to other instance?

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

PiotrI_0-1744294341660.png

 

That's the UI Action I did, when I click on it in PDI:

PiotrI_1-1744294406090.png

 

And than the window about opening the link, after I click OK it is opening the teams URL in new TAB with a pop-up if I want to open the Microsoft Teams.

 

Let's just focus now on the form and leave the workspace out 😉

 

@PiotrI 

the 2nd alert didn't come?

So it's issue with that encodeURIComponent

Try user.email.toString() in encodeURIComponent

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

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

They second alert came but had internal data in it. I will try your suggestion 🙂

 

*EDIT - same outcome, two alerts but no new tab opened