ICE Partners Интеграция 3CX Phone System c Microsoft CRM 4.0. Исходящие вызовы.
Краткое описание Данное руководство описывает пошаговую настройку возможности осуществления исходящих вызовов из Microsoft CRM и использование 3CX Phone System. При нажатии кнопки Позвонить происходит вызов на внутренний номер звонящего (для того чтобы он поднял трубку), далее на номер вызываемого абонента. Приведенный в руководстве скрипт, разрабатывался и тестировался для MS CRM 4.0 и 3CX v.7 Скрипт разработан www.icepartners.ru и распространяется бесплатно. Поддержка и модификация данного решения может быть осуществлена на платной основе.
Для хранения внутреннего номера используется поле Основной телефон (имя схемы address1_telephone1), сущность Пользователь.
Для сущности Контакт необходимо создать кнопку Позвонить. Создайте атрибут Call (имя схемы new_button, тип текст), для сущности Контакт.
Добавьте поле Call на форму Контакт.
Добавьте скрипт на событие OnLoad. //Определение внутреннего номера пользователя CRM 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(); // Скрипт для создание кнопки crmform.all.new_button.datavalue = "Позвонить"; 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(); 192.168.0.2 - необходимо заменить на адрес 3CX сервера. Скрипт работает при условии ПИН = Внутреннему Номеру.
Результат в форме контакта.