Search This Blog

Showing posts with label CRM HTML. Show all posts
Showing posts with label CRM HTML. Show all posts

Friday, June 23, 2017

Click Phone Number on HTML page calling with Skype as similar to Dynamics CRM Phone Number

Click Phone Number on HTML page calling with Skype as similar to Dynamics CRM Phone Number

On CRM, we are embedded the HTML page in the contact screen. In HTML page there is a phone number link(anchor tag) button.

When user click the field need to call with Skype as similar to Dynamics CRM.




On the HTML page we have to create a anchor tag

  <a href="callto:768-555-0156" id="iAnchor"  onclick="return Test();" use_skype_protocol_grid="True" country_code="+91" title="Prefix the number with &quot;+<country code><area code>&quot; and install Skype to make calls from Microsoft Dynamics 365.">768-555-0156</a>

Attribute Definitions:
href= callto:Phonenumber
use_skype_protocol_grid= call in skype or skypeBusiness/Lync(Administrator->SystemSetting->Set the telephone provider)
country_code= (Administrator->SystemSetting->Default country/code region)



 function Test() {
  //Syntax        //Mscrm.Shortcuts.openPhoneWindow(phoneNumber,LOCID_COUNTRY_CODE,LOCID_USE_SKYPE_PROTOCOL)

    parent.Mscrm.Shortcuts.openPhoneWindow("768-555-0156", "+91", "true")
 }

The below is the original method in the Dynamics CRM  "_static/_grid/action.js"
//_static/_grid/action.js
function openPhoneNumberFromGrid(e)
{
    try
    {
        var o = e.target || e.srcElement;
        if(!IsNull(o))
        {
            while(o.tagName != "A")
                o = o.parentNode;
            var phoneNumber = XUI.Html.GetText(o),
                LOCID_COUNTRY_CODE = "",
                LOCID_USE_SKYPE_PROTOCOL = "";
            if(!isNullOrEmptyString(phoneNumber))
            {
                if(o.hasAttribute("country_code"))
                    LOCID_COUNTRY_CODE = o.getAttribute("country_code");
                LOCID_USE_SKYPE_PROTOCOL = o.getAttribute("USE_SKYPE_PROTOCOL_GRID");
                Mscrm.Shortcuts.openPhoneWindow(phoneNumber,LOCID_COUNTRY_CODE,LOCID_USE_SKYPE_PROTOCOL)
            }
        }
    }
    catch(e)
    {
    }
    return false
}




Click phone number in CRM automatically call go in Skype or Skype for Business

Click phone number in CRM automatically call go in Skype or Skype for Business
Whenever click the skype icon or phone number, we want to call automatically through skype for business or skype.




There are two ways we could achieve it
1)Default CRM method call
2)Using javascript

1) Default CRM method call

Code:

Mscrm.Shortcuts.openPhoneWindow('789-852-987','+1','true');

Output:


 Behind the code  "Mscrm.Shortcuts.openPhoneWindow" in CRM

openPhoneWindow = function (phoneNumber, countryCode, useSkypeProtocol) {
    var $v_0 = "tel";
    $v_1 = (new parent.Mscrm.PhoneUriBuilder).buildUri(phoneNumber, countryCode, $v_0),
    $v_2 = parent.Mscrm.CrmUri.createForOrganization($v_1, null);
    $v_2.checkParamsNoEqual = true;
    safeWindowOpen($v_2, "", "")
};
function safeWindowOpen(url, name, features, replace, disablePopupWarning) {
    var $v_0 = null;
    //if (!IsNull(url))
    $v_0 = url.toString();
    //  else $v_0 = "";
    //if (IsNull(features))
    features = "";
    parent.Mscrm.PerformanceTracing.write("Navigate", $v_0);
    var $v_1 = null;
    try {
        if (parent.Mscrm.CrmWindow.$3C && parent.Mscrm.Utilities.isChrome()) features = $7x(features, "status=1");
        parent.Mscrm.CrmWindow.$3C = true;
        var $v_2 = new Date;
        if (window.name === name)
            //The below line of code only open skype window.....
            $v_1 = parent.masterWindow().open($v_0, name, features, replace);
        else
            $v_1 = window.open($v_0, name, features, replace);
        attachErrorHandler($v_1);
        try {
            $v_1.focus()
        } catch (e) { }
        var $v_3 = new Date;
        $9p($v_1, $v_2.getTime(), $v_3.getTime());
        $v_1._masterWindow = masterWindow()
    } catch ($$e_9) { }
    //IsNull($v_1) && !disablePopupWarning && handlePopupBlockerError($v_0);
    return $v_1
}

function Test() {
    openPhoneWindow("768-555-0156", "+91", "false")
}
 

2) Using Javascript:

Code:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
    <script type="text/javascript" src="http://www.skypeassets.com/i/scom/js/skype-uri.js"></script>
<body>
    <a href="tel:23456789">Call</a>
</body>
</html>

Output: