Deep dive: Initiate Teams call from record context
| Warning | Work in progress! We are in the process of updating the information on this page. Subject to change. |
In this guide, we will demonstrate how to initiate a Microsoft Teams call directly from the Resco Mobile app. Utilizing deep links, with record details, we allow users to initiate a call with a single contact via the Contact form button or with multiple contacts via the multiselect command in the Contact view. The script extracts email addresses from the selected records and initiates a Teams call with those participants.
This approach is adaptable to any deep link actions, not limited to Microsoft Teams.
Prerequisites
For this script to function properly, the following conditions must be met:
- The Microsoft Teams application must be installed on the device.
- The contact's email address must correspond to the associated contact in the user's Teams.
Download sample files
For your convenience, we are providing you sample file: File:StartTeamsCall.zip
Set up your app project
In this section, we add the JavaScript code to your app project.
- Start Woodford and edit the app project used for opening the questionnaire.
- Go to Components > Offline HTML.
- Upload the attached file [script].html or use New File template and paste the script below, inside the <script></script> tags.
- Verify that the Offline HTML folder also includes an updated version of JSBridge.js (used for facilitating the communication between our custom script and the app). Also, the uploaded script must link to that file. See Including the JSBridge.js file for detailed instructions.
- Save all changes and publish the app project.
About the script
The script is triggered by a command. To trigger the action, we created a custom command on both the form (linked to a button) and the view (set as a multiselect action). After the trigger, the entity(s) context is collected, and the contact's email is stored in the "users" array. From this array, we then construct the Teams deep link and start the call.
const COMMAND_NAME = "custom_callTeams";
function openTeamsCall(context) {
let entities = context.entities
let users = [];
// Collect all selected entities' emails
for (let i = 0; i < entities.length; i++) {
let props = entities[i].properties
let user = (props.emailaddress1 || "").toString().trim();
if (user) {
users.push(user);
}
}
if (users.length === 0) {
MobileCRM.bridge.alert("No valid email addresses found in selected records.");
return;
}
let url = "https://teams.microsoft.com/l/call/0/0?users=" + encodeURIComponent(users.join(",")) + "&withVideo=false";
MobileCRM.Platform.openUrl(url);
}
window.onload = function() {
// EntityForm command (for single entity form)
MobileCRM.UI.EntityForm.onCommand(COMMAND_NAME, function(entityForm) {
openTeamsCall({ entities: [entityForm.entity] });
}, true, null);
// EntityList command (for multiselect on list view)
MobileCRM.UI.EntityList.onCommand(COMMAND_NAME, function(entityList) {
openTeamsCall(entityList.context);
}, true, null);
};