Create attribute new_ext (type nvchar)
Change 192.168.0.2 to your 3cx server ip
telephone1 - called number
Add this script to OnLoad event
Tested only with MS CRM 3.0
- Code: Select all
//Take crm user extension
var xml = "" + "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
" <soap:Body>" +
" <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\" xmlns=\"http://schemas.microsoft.com/crm/2006/WebServices\">" +
" <q1:EntityName>systemuser</q1:EntityName>" +
" <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
" <q1:Attributes>" +
" <q1:Attribute>systemuserid</q1:Attribute>" +
" <q1:Attribute>fullname</q1:Attribute>" +
" <q1:Attribute>new_ext</q1:Attribute>" +
" </q1:Attributes>" +
" </q1:ColumnSet>" +
" <q1:Distinct>false</q1:Distinct>" +
" <q1:Criteria>" +
" <q1:FilterOperator>And</q1:FilterOperator>" +
" <q1:Conditions>" +
" <q1:Condition>" +
" <q1:AttributeName>systemuserid</q1:AttributeName>" +
" <q1:Operator>EqualUserId</q1:Operator>" +
" </q1:Condition>" +
" </q1:Conditions>" +
" </q1:Criteria>" +
" </query>" +
" </soap:Body>" +
"</soap:Envelope>" + "";
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2006/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2006/WebServices/RetrieveMultiple");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length); xmlHttpRequest.send(xml);
var doc = xmlHttpRequest.responseXML; var user = doc.selectSingleNode("//BusinessEntity");
var userId = user.selectSingleNode("systemuserid").text;
var userName = user.selectSingleNode("fullname").text;
var ext= user.selectSingleNode("new_ext").text;
// Create call button
crmForm.all.new_button.DataValue = "Call";
// We could align it a bit
crmForm.all.new_button.style.textAlign = "center";
crmForm.all.new_button.vAlign = "middle";
//we make the mouse look as a hand when we're moving over
crmForm.all.new_button.style.cursor = "hand";
crmForm.all.new_button.style.backgroundColor = "#CADFFC";
crmForm.all.new_button.style.color = "#FF0000";
crmForm.all.new_button.style.borderColor = "#330066";
crmForm.all.new_button.style.fontWeight = "bold";
crmForm.all.new_button.contentEditable = false;
//we attach some events in order to make it look nice :)
crmForm.all.new_button.attachEvent("onmousedown",color1);
crmForm.all.new_button.attachEvent("onmouseup",color2);
crmForm.all.new_button.attachEvent("onmouseover",color3);
crmForm.all.new_button.attachEvent("onmouseleave",color4);
function color3() {
crmForm.all.new_button.style.backgroundColor = "#6699FF";
}
function color4() {
crmForm.all.new_button.style.backgroundColor = "CADFFC";
}
function color1() {
crmForm.all.new_button.style.color = "000099";
}
function color2() {
crmForm.all.new_button.style.color = "FF0000";
}
//Call function
function call() {
var to=crmForm.all.telephone1.DataValue;
var url = "http://192.168.0.2:5481/make_call.php?extnum=" + ext + "&vmpin=" + ext + "&to=" + to;
alert(url);
call_window=window.open(url)
call_window.close();
}
crmForm.all.new_button.attachEvent("onclick",call);
Result

