3cx + Microsoft CRM

Status
Not open for further replies.

ice

Joined
Jun 11, 2008
Messages
108
Reaction score
0
Call from MS CRM

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:
//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
 
has anyone used this in microsoft crm 4.0?

cheers,
 
Re: 3cx v7 + Microsoft CRM 4.0

User extension in address1_telephone1 - Main phone field(USER entity)
Change 192.168.0.2 to your 3cx server ip
telephone1 - called number
Add this script to OnLoad event

Tested with MS CRM 4.0 + 3CX v7

Code:
//Take crm user extension
function GetUserExt()
  {
                   var XMLRequest = "" + 
                   "<?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\">" + GenerateAuthenticationHeader() +
                   " <soap:Body>" + 
                   " <RetrieveMultiple xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + 
                   " <query xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryExpression\">" + 
                   " <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>address1_telephone1</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>" + 
                   " </RetrieveMultiple>" + 
                   " </soap:Body>" + 
                   "</soap:Envelope>" + 
                   "";
    
                   try
                   {
  
                   var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                   xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
                   xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
                   xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
                   xmlHttpRequest.setRequestHeader("Content-Length", XMLRequest.length);
                   xmlHttpRequest.send(XMLRequest);
  
                   var Result = xmlHttpRequest.responseXML;
                   var BusinessEntityNodes = Result.selectNodes("//RetrieveMultipleResult/BusinessEntities/BusinessEntity");

                   if (BusinessEntityNodes.length != 0)
                   {  
                                    var BusinessEntityNode = BusinessEntityNodes[0]; 
                                    var SystemUserId = BusinessEntityNode.selectSingleNode("q1:systemuserid");
                                    var FullName = BusinessEntityNode.selectSingleNode("q1:fullname");
                                    var Extension = BusinessEntityNode.selectSingleNode("q1:address1_telephone1");
  
                                    
                                    var SystemUserId = (SystemUserId == null) ? null : SystemUserId.text;
                                    var FullName = (FullName == null) ? null : FullName.text;
                                    var Extension = (Extension == null) ? null : Extension.text;
                       
                    }
                                    return Extension;
                   }
                   catch (e)
                   {
                                    alert(e.message);
                   }
  
                    
  
  }
  alert(GetUserExt());
  var ext = GetUserExt();

// Create call button
crmForm.all.new_button.DataValue = "Call";
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;
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";
}
crmForm.all.new_button.attachEvent("onclick",call);
//Функция вызова
function call() {
var to=crmForm.all.telephone1.DataValue;
var url = "http://192.168.0.2:5484/PbxAPI.aspx?func=make_call&from=" + ext + "&pin=" + ext + "&to=" + to;
alert(url);
call_window=window.open(url)
call_window.close();
}
 
hi there

im a bit of a newbiw when it comes to CRM

can you tell me what parts i need to modify for this to work with our system

also where do i need to place this script for it to work

i changed the server ip and placed it in a on load event for phone call to see what happens

all i got was a box appear with our number and ok. then an error about making the button.

does this script need o be put in a few places in order to get the users extension number.

also when this finally works will it dial the number directly to the softphone or will it do the make call option and put the user on hold whilst it dials the customer.

im eager to get this working as our sales team keep moaning its to loud and they want headsets as well as having the ability to dial from the crm..

if someone could get back to me as soon as they can with an answer i would greatly appreciate it.

thanks

jay
 
Hi Jay,
Your CRM version?
Also need screenshot of error.

Extension number takes from new_ext field (USER entity)
Did you create it?

Script use HTTP API - this mean first call to user extension, after on hold and call to costumer.
 
hi ice

sorry the crm is 4.0 dynamics

Extension number takes from new_ext field (USER entity)
Did you create it?

where do i need to create this. sorry im really new to this and havnt been given enough time to really play with it.

all i did was paste your script under the on load option of the phone call form.
i changed the server ip also.

is there a way round the call to extension first then dial out.. i think this may irritate our sales staff. they cant seem to wait :lol:

ive added the error message for you.

im guessing its something i have done wrong but as a complete novice i cannot begin to understand where :oops:

thanks for your help

jay
 

Attachments

  • crm.jpg
    crm.jpg
    15.2 KB · Views: 2,302
In FORM CONSTRUCTOR create text field (attribute) new_button in LEAD entity and create new_ext field(attribute) in USER entity

Possible this manual help, but it on Russian
http://icepartners.ru/integraciya-3cx-s-microsoft-crm-4.0.html
 
hi there

thanks very muh for your help

i have it working. the pictures helped a bit :lol:

this only works if the sales staff go into the contacts page.

is there a way of adding this to other pages. espeially the phone call page. this way the sales person can fill in the form and select who they need to call then simply press call.

im not sure how much more difficult this will make things.

it would be nice if the call could be sent straight out of the crm system much like outlook does instead of getting the make call system.

do you know of a way this can be achieved ??

thanks again for all your help it is greatly appreciated.

thanks jay
 
Do the same for ORGANIZATION and LEADS entities.
change in this string telephone1 to field name with phone number

var to=crmForm.all.telephone1.DataValue;

I think direct call without greeting is possible, but it is serious coding for TAPI.
 
hi there

thanks for all your help

we have found a bit of software that apparently can do a tapi version but is not cheap for a small company.

i will update these areas and see if the sales team are happy with that if not then we may go down this other route but im sure once they get the bill they will change their mind :)

thanks again for all you help

jay
 
Status
Not open for further replies.

Latest Posts

Forum statistics

Threads
111,885
Messages
589,545
Members
164,744
Latest member
johnblackwood1