RE: button 'contact via whatsapp' based on the contact mobile number
Hi Renato,
I created a solution and included following components:
- a custom form which contains a custom field called WhatsApp ID
- whatsapp icon 16x16 png
- whatsapp icon 32x32 png
- whatsapp icon 16x16 svg
- jscript with custom functions

Then I added a new button to the form, bind open WhatsApp function to the button with Ribbon Workbench.
By using Xrm.Navigation.openUrl function, it'll wake up WhatsApp if you had installed the application.
I tested in iOS 13.3, CRM application version is 13.19122.10.
Code:
function openWhatsApp() {
var url = "https://wa.me/";
var id = "";
if (Xrm.Page.getAttribute("new_whatsappid") !== null) {
if (Xrm.Page.getAttribute("new_whatsappid").getValue() !== null &&
Xrm.Page.getAttribute("new_whatsappid").getValue() !== "") {
id = Xrm.Page.getAttribute("new_whatsappid").getValue();
Xrm.Navigation.openUrl(url id);
} else {
alertDialog("Notice", "There is no whatsapp id for current contact.");
}
}
}
function alertDialog(title_val, text_val) {
var alertStrings = {
confirmButtonLabel: "Ok",
text: text_val,
title: title_val
};
var alertOptions = {
height: 150,
width: 250
};
Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(
function success(result) {
console.log("Alert dialog closed");
},
function (error) {
console.log(error.message);
}
);
}
Regards,
Clofly