AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Разработка
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 03.06.2009, 10:17   #1  
Murzin Andrey is offline
Murzin Andrey
Участник
 
12 / 10 (1) +
Регистрация: 03.06.2009
Адрес: Россия
Использование веб сервисов.
Здравствуйте, уважаемые.
Сразу скажу, что только начинаю разбираться с CRM 4.0 и могу написать что-нибудь не то, но всё же (читаю SDK).
Проблема такая - в форме Интерес добавлено поле типа lookup (выбирается бизнес-партнер), нужно вычитать Название этой организации, Телефон и вставить в соответствующие поля в форме Интерес.
Насколько я понял по форумам делается это с помощью вэб сервисов.
Пытаюсь сделать, результат следующий: название ставится, телефон нет.
Вопрос как вставить телефон.

Вот что я делаю: на событие OnChange поля customerid (добавленный lookup) вешаю такой код:

var lookupItem = new Array;

lookupItem = crmForm.all.customerid.DataValue;
if (lookupItem[0] != null)
{
alert(crmForm.all.companyname.DataValue = lookupItem[0].name);
alert(lookupItem[0].id);
}

var accountid = "lookupItem[0].id";
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
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'>"+
authenticationHeader+
"<soap:Body>"+
"<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>account</entityName>"+
"<id>"+accountid+"</id>"+
"<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>telephone1</q1:Attribute>"+
"</q1:Attributes>"+
"</columnSet>"+
"</Retrieve>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;

// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display the retrieved value.
else
{
alert(resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue);

crmForm.all.telephone1.DataValue = alert(lookupItem[0].telephone1);
}
Старый 03.06.2009, 10:55   #3  
Murzin Andrey is offline
Murzin Andrey
Участник
 
12 / 10 (1) +
Регистрация: 03.06.2009
Адрес: Россия
Я правильно понял, что этот код нужно вешать на OnChange поля customerid ?
Старый 03.06.2009, 11:00   #4  
slivka_83 is offline
slivka_83
Консультант-джедай
Аватар для slivka_83
MCBMSS
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
1,683 / 374 (16) ++++++
Регистрация: 18.12.2008
Адрес: default city
А при каком событии Вы хотите подтягивать телефон?
__________________
Крокодил, крокожу и буду крокодить.
Человек человеку - волк , а зомби зомби - зомби.
Экстремал и буду экстремать!
Блога
Старый 03.06.2009, 11:00   #5  
Bondonello is offline
Bondonello
Kostya Afendikov
Аватар для Bondonello
MCBMSS
Лучший по профессии 2009
 
510 / 106 (5) +++++
Регистрация: 06.06.2008
Адрес: Украина
Да, вставляете функцию и ее вызов.
Старый 03.06.2009, 12:02   #6  
Murzin Andrey is offline
Murzin Andrey
Участник
 
12 / 10 (1) +
Регистрация: 03.06.2009
Адрес: Россия
Цитата:
Сообщение от slivka_83 Посмотреть сообщение
А при каком событии Вы хотите подтягивать телефон?
При выборе бизнес-партнера в lookup.
Старый 03.06.2009, 12:14   #7  
Артем Enot Грунин is offline
Артем Enot Грунин
Moderator
Аватар для Артем Enot Грунин
MCBMSS
Злыдни
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,912 / 623 (28) +++++++
Регистрация: 16.08.2007
Адрес: Пермь!
Записей в блоге: 151
Цитата:
Сообщение от Murzin Andrey Посмотреть сообщение
Здравствуйте, уважаемые.
Пытаюсь сделать, результат следующий: название ставится, телефон нет.
Вопрос как вставить телефон.

// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display the retrieved value.
else
{
alert(resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue);

crmForm.all.telephone1.DataValue = alert(lookupItem[0].telephone1);
}
Вы не используете значение которое получили из сервиса.
Код:
crmForm.all.telephone1.DataValue = resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue;
__________________
http://fixrm.wordpress.com, снятие/наведение порчи. Быстро, дорого, гарантия.

MS Certified Dirty Magic Professional

Последний раз редактировалось Артем Enot Грунин; 03.06.2009 в 12:18.
Старый 03.06.2009, 12:14   #8  
slivka_83 is offline
slivka_83
Консультант-джедай
Аватар для slivka_83
MCBMSS
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
1,683 / 374 (16) ++++++
Регистрация: 18.12.2008
Адрес: default city
Тогда если это новое поле, то оно не может быть customerid! у него должен быть префикс
__________________
Крокодил, крокожу и буду крокодить.
Человек человеку - волк , а зомби зомби - зомби.
Экстремал и буду экстремать!
Блога
Старый 03.06.2009, 12:15   #9  
Артем Enot Грунин is offline
Артем Enot Грунин
Moderator
Аватар для Артем Enot Грунин
MCBMSS
Злыдни
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,912 / 623 (28) +++++++
Регистрация: 16.08.2007
Адрес: Пермь!
Записей в блоге: 151
Цитата:
Сообщение от slivka_83 Посмотреть сообщение
Тогда если это новое поле, то оно не может быть customerid! у него должен быть префикс
Интерес уже связан с Клиентом. Это стандартное поле
__________________
http://fixrm.wordpress.com, снятие/наведение порчи. Быстро, дорого, гарантия.

MS Certified Dirty Magic Professional
Старый 03.06.2009, 12:38   #10  
Murzin Andrey is offline
Murzin Andrey
Участник
 
12 / 10 (1) +
Регистрация: 03.06.2009
Адрес: Россия
Цитата:
Сообщение от Артем Enot Грунин Посмотреть сообщение
Вы не используете значение которое получили из сервиса.
Код:
crmForm.all.telephone1.DataValue = resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue;
Делаю с таким кодом, пишет ошибку "An unexpected error occurred"


Кто делал похожую работу, может покажете код )). Буду оч. благодарен.
Старый 03.06.2009, 12:54   #11  
a33ik is offline
a33ik
Чайный пьяница
Аватар для a33ik
MCP
MCBMSS
Злыдни
Соотечественники
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,243 / 896 (36) +++++++
Регистрация: 02.07.2008
Адрес: Greenville, SC
Цитата:
Сообщение от Murzin Andrey Посмотреть сообщение
Делаю с таким кодом, пишет ошибку "An unexpected error occurred"


Кто делал похожую работу, может покажете код )). Буду оч. благодарен.
Весь свой код приведите, пожалуйста, для работы над ошибками.
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством.

Подписывайтесь на мой блог, twitter и YouTube канал.
Пользуйтесь моим Ultimate Workflow Toolkit
Старый 03.06.2009, 13:01   #12  
Murzin Andrey is offline
Murzin Andrey
Участник
 
12 / 10 (1) +
Регистрация: 03.06.2009
Адрес: Россия
Спасибо, разобрался. Заработало.

Только теперь другая проблема. При выборе бизнес-партнера появляются сообщения со значениями искомых полей. Как их убрать? ))

Код такой:

var lookupItem = new Array;

lookupItem = crmForm.all.customerid.DataValue;

var accountid = "lookupItem[0].id";
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
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'>"+
authenticationHeader+
"<soap:Body>"+
"<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>account</entityName>"+
"<id>"+lookupItem[0].id+"</id>"+
"<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>telephone1</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>name</q1:Attribute>"+
"</q1:Attributes>"+

"</columnSet>"+
"</Retrieve>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;

// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display the retrieved value.
else
{
alert(resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue);
alert(resultXml.selectSingleNode("//q1:name").nodeTypedValue);

crmForm.all.telephone1.DataValue = resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue;
crmForm.all.companyname.DataValue = resultXml.selectSingleNode("//q1:name").nodeTypedValue;
}
Старый 03.06.2009, 13:05   #13  
a33ik is offline
a33ik
Чайный пьяница
Аватар для a33ik
MCP
MCBMSS
Злыдни
Соотечественники
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,243 / 896 (36) +++++++
Регистрация: 02.07.2008
Адрес: Greenville, SC
Цитата:
Сообщение от Murzin Andrey Посмотреть сообщение
Спасибо, разобрался. Заработало.

Только теперь другая проблема. При выборе бизнес-партнера появляются сообщения со значениями искомых полей. Как их убрать? ))

Код такой:

var lookupItem = new Array;

lookupItem = crmForm.all.customerid.DataValue;

var accountid = "lookupItem[0].id";
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
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'>"+
authenticationHeader+
"<soap:Body>"+
"<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>account</entityName>"+
"<id>"+lookupItem[0].id+"</id>"+
"<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>telephone1</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>name</q1:Attribute>"+
"</q1:Attributes>"+

"</columnSet>"+
"</Retrieve>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;

// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display the retrieved value.
else
{
alert(resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue);
alert(resultXml.selectSingleNode("//q1:name").nodeTypedValue);


crmForm.all.telephone1.DataValue = resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue;
crmForm.all.companyname.DataValue = resultXml.selectSingleNode("//q1:name").nodeTypedValue;
}
Все alert() конструкции убеите и будет Вам счастье.
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством.

Подписывайтесь на мой блог, twitter и YouTube канал.
Пользуйтесь моим Ultimate Workflow Toolkit
Старый 03.06.2009, 13:34   #14  
Murzin Andrey is offline
Murzin Andrey
Участник
 
12 / 10 (1) +
Регистрация: 03.06.2009
Адрес: Россия
Так идём дальше
Всё работает, нормально, НО только если искомое поле заполнено.
Если хоть одно поле пустое, то код не работает, ничего не вставляется.
Как быть?
Старый 03.06.2009, 13:39   #15  
a33ik is offline
a33ik
Чайный пьяница
Аватар для a33ik
MCP
MCBMSS
Злыдни
Соотечественники
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,243 / 896 (36) +++++++
Регистрация: 02.07.2008
Адрес: Greenville, SC
Цитата:
Сообщение от Murzin Andrey Посмотреть сообщение
Так идём дальше
Всё работает, нормально, НО только если искомое поле заполнено.
Если хоть одно поле пустое, то код не работает, ничего не вставляется.
Как быть?
Сделайте проверку вроде такой:

Код:
if (crmForm.all.customerid.DataValue != null && crmForm.all.customerid.DataValue[0] != null)
{
//вытаскивание телефона, запись в необходимое поле
}
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством.

Подписывайтесь на мой блог, twitter и YouTube канал.
Пользуйтесь моим Ultimate Workflow Toolkit
Старый 03.06.2009, 13:50   #16  
Murzin Andrey is offline
Murzin Andrey
Участник
 
12 / 10 (1) +
Регистрация: 03.06.2009
Адрес: Россия
Не помогло,
ошибка "Требуется объект"
Старый 03.06.2009, 14:08   #17  
a33ik is offline
a33ik
Чайный пьяница
Аватар для a33ik
MCP
MCBMSS
Злыдни
Соотечественники
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,243 / 896 (36) +++++++
Регистрация: 02.07.2008
Адрес: Greenville, SC
Цитата:
Сообщение от Murzin Andrey Посмотреть сообщение
Не помогло,
ошибка "Требуется объект"
Код приведите. Я, к сожалению, не телепат.
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством.

Подписывайтесь на мой блог, twitter и YouTube канал.
Пользуйтесь моим Ultimate Workflow Toolkit
Старый 03.06.2009, 14:18   #18  
Murzin Andrey is offline
Murzin Andrey
Участник
 
12 / 10 (1) +
Регистрация: 03.06.2009
Адрес: Россия
Код следующий:

var lookupItem = new Array;

lookupItem = crmForm.all.customerid.DataValue;

var accountid = "lookupItem[0].id";
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
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'>"+
authenticationHeader+
"<soap:Body>"+
"<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>account</entityName>"+
"<id>"+lookupItem[0].id+"</id>"+
"<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>telephone1</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>name</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>address1_line1</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>address1_city</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>revenue</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>numberofemployees</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>industrycode</q1:Attribute>"+
"</q1:Attributes>"+

"</columnSet>"+
"</Retrieve>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;

// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display the retrieved value.
else
{
if (crmForm.all.customerid.DataValue != null && crmForm.all.customerid.DataValue[0] != null)
{
resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue;
resultXml.selectSingleNode("//q1:name").nodeTypedValue;
resultXml.selectSingleNode("//q1:address1_line1").nodeTypedValue;
resultXml.selectSingleNode("//q1:address1_city").nodeTypedValue;
resultXml.selectSingleNode("//q1:revenue").nodeTypedValue
resultXml.selectSingleNode("//q1:numberofemployees").nodeTypedValue;
resultXml.selectSingleNode("//q1:industrycode").nodeTypedValue;

crmForm.all.telephone1.DataValue = resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue;

crmForm.all.companyname.DataValue = resultXml.selectSingleNode("//q1:name").nodeTypedValue;

crmForm.all.address1_line1.DataValue = resultXml.selectSingleNode("//q1:address1_line1").nodeTypedValue;

crmForm.all.address1_city.DataValue = resultXml.selectSingleNode("//q1:address1_city").nodeTypedValue;

crmForm.all.revenue.DataValue = resultXml.selectSingleNode("//q1:revenue").nodeTypedValue;

crmForm.all.numberofemployees.DataValue = resultXml.selectSingleNode("//q1:numberofemployees").nodeTypedValue;

crmForm.all.industrycode.DataValue = resultXml.selectSingleNode("//q1:industrycode").nodeTypedValue;
}
}
Старый 03.06.2009, 14:30   #19  
a33ik is offline
a33ik
Чайный пьяница
Аватар для a33ik
MCP
MCBMSS
Злыдни
Соотечественники
Most Valuable Professional
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,243 / 896 (36) +++++++
Регистрация: 02.07.2008
Адрес: Greenville, SC
Lightbulb
Цитата:
Сообщение от Murzin Andrey Посмотреть сообщение
Код следующий:

var lookupItem = new Array;

lookupItem = crmForm.all.customerid.DataValue;

var accountid = lookupItem[0].id;
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
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'>"+
authenticationHeader+
"<soap:Body>"+
"<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>account</entityName>"+
"<id>"+lookupItem[0].id+"</id>"+
"<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>telephone1</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>name</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>address1_line1</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>address1_city</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>revenue</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>numberofemployees</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>industrycode</q1:Attribute>"+
"</q1:Attributes>"+

"</columnSet>"+
"</Retrieve>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;

// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display the retrieved value.
else
{
if (crmForm.all.customerid.DataValue != null && crmForm.all.customerid.DataValue[0] != null)
{
resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue;
resultXml.selectSingleNode("//q1:name").nodeTypedValue;
resultXml.selectSingleNode("//q1:address1_line1").nodeTypedValue;
resultXml.selectSingleNode("//q1:address1_city").nodeTypedValue;
resultXml.selectSingleNode("//q1:revenue").nodeTypedValue
resultXml.selectSingleNode("//q1:numberofemployees").nodeTypedValue;
resultXml.selectSingleNode("//q1:industrycode").nodeTypedValue;

crmForm.all.telephone1.DataValue = resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue;

crmForm.all.companyname.DataValue = resultXml.selectSingleNode("//q1:name").nodeTypedValue;

crmForm.all.address1_line1.DataValue = resultXml.selectSingleNode("//q1:address1_line1").nodeTypedValue;

crmForm.all.address1_city.DataValue = resultXml.selectSingleNode("//q1:address1_city").nodeTypedValue;

crmForm.all.revenue.DataValue = resultXml.selectSingleNode("//q1:revenue").nodeTypedValue;

crmForm.all.numberofemployees.DataValue = resultXml.selectSingleNode("//q1:numberofemployees").nodeTypedValue;

crmForm.all.industrycode.DataValue = resultXml.selectSingleNode("//q1:industrycode").nodeTypedValue;
}
}
Сам не тестировал, но попробуйте так:

Код:
if (crmForm.all.customerid.DataValue != null && crmForm.all.customerid.DataValue[0] != null)
{
var lookupItem = new Array;

lookupItem = crmForm.all.customerid.DataValue;

var accountid = lookupItem[0].id;
var authenticationHeader = GenerateAuthenticationHeader();

// Prepare the SOAP message.
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'>"+
authenticationHeader+
"<soap:Body>"+
"<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>account</entityName>"+
"<id>"+lookupItem[0].id+"</id>"+
"<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>telephone1</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>name</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>address1_line1</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>address1_city</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>revenue</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>numberofemployees</q1:Attribute>"+
"</q1:Attributes>"+

"<q1:Attributes>"+
"<q1:Attribute>industrycode</q1:Attribute>"+
"</q1:Attributes>"+

"</columnSet>"+
"</Retrieve>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;

// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display the retrieved value.
else
{
crmForm.all.telephone1.DataValue = resultXml.selectSingleNode("//q1:telephone1") == null ? "" : resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue;

crmForm.all.companyname.DataValue = resultXml.selectSingleNode("//q1:name") == null ? "" : resultXml.selectSingleNode("//q1:name").nodeTypedValue;

crmForm.all.address1_line1.DataValue = resultXml.selectSingleNode("//q1:address1_line1") == null ? "" : resultXml.selectSingleNode("//q1:address1_line1").nodeTypedValue;

crmForm.all.address1_city.DataValue = resultXml.selectSingleNode("//q1:address1_city") = null ? "" : resultXml.selectSingleNode("//q1:address1_city").nodeTypedValue;

crmForm.all.revenue.DataValue = resultXml.selectSingleNode("//q1:revenue") == null ? "" : resultXml.selectSingleNode("//q1:revenue").nodeTypedValue;

crmForm.all.numberofemployees.DataValue = resultXml.selectSingleNode("//q1:numberofemployees") == null ? "" : resultXml.selectSingleNode("//q1:numberofemployees").nodeTypedValue;

crmForm.all.industrycode.DataValue = resultXml.selectSingleNode("//q1:industrycode") == null ? "" : resultXml.selectSingleNode("//q1:industrycode").nodeTypedValue;

}
}
__________________
Эмо разработчик, сначала пишу код, потом плачу над его несовершенством.

Подписывайтесь на мой блог, twitter и YouTube канал.
Пользуйтесь моим Ultimate Workflow Toolkit
Старый 03.06.2009, 14:53   #20  
Murzin Andrey is offline
Murzin Andrey
Участник
 
12 / 10 (1) +
Регистрация: 03.06.2009
Адрес: Россия
Так тоже не работает.

Пробую каждое поле проверять, тоже не работает:
Цитата:
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display the retrieved value.
else
{
if (resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue != null)
{
alert(resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue);
crmForm.all.telephone1.DataValue = resultXml.selectSingleNode("//q1:telephone1").nodeTypedValue;
}
if (resultXml.selectSingleNode("//q1:name").nodeTypedValue != null)
{
alert(resultXml.selectSingleNode("//q1:name").nodeTypedValue);
crmForm.all.companyname.DataValue = resultXml.selectSingleNode("//q1:name").nodeTypedValue;
}

if (resultXml.selectSingleNode("//q1:address1_line1").nodeTypedValue != null)
{
alert(resultXml.selectSingleNode("//q1:address1_line1").nodeTypedValue);
crmForm.all.address1_line1.DataValue = resultXml.selectSingleNode("//q1:address1_line1").nodeTypedValue;
}
if (resultXml.selectSingleNode("//q1:address1_city").nodeTypedValue != null)
{
alert(resultXml.selectSingleNode("//q1:address1_city").nodeTypedValue);
crmForm.all.address1_city.DataValue = resultXml.selectSingleNode("//q1:address1_city").nodeTypedValue;
}
if (resultXml.selectSingleNode("//q1:address1_stateorprovince").nodeTypedValue != null)
{
alert(resultXml.selectSingleNode("//q1:address1_stateorprovince").nodeTypedValue);
crmForm.all.address1_stateorprovince.DataValue = resultXml.selectSingleNode("//q1:address1_stateorprovince").nodeTypedValue;
}
if (resultXml.selectSingleNode("//q1:address1_postalcode").nodeTypedValue != null)
{
alert(resultXml.selectSingleNode("//q1:address1_postalcode").nodeTypedValue);
crmForm.all.address1_postalcode.DataValue = resultXml.selectSingleNode("//q1:address1_postalcode").nodeTypedValue;
}
if (resultXml.selectSingleNode("//q1:address1_country").nodeTypedValue != null)
{
alert(resultXml.selectSingleNode("//q1:address1_country").nodeTypedValue);
crmForm.all.address1_country.DataValue = resultXml.selectSingleNode("//q1:address1_country").nodeTypedValue;
}
if (resultXml.selectSingleNode("//q1:revenue").nodeTypedValue != null)
{
alert(resultXml.selectSingleNode("//q1:revenue").nodeTypedValue);
crmForm.all.revenue.DataValue = resultXml.selectSingleNode("//q1:revenue").nodeTypedValue;
}
if (resultXml.selectSingleNode("//q1:numberofemployees").nodeTypedValue != null)
{
alert(resultXml.selectSingleNode("//q1:numberofemployees").nodeTypedValue);
crmForm.all.numberofemployees.DataValue = resultXml.selectSingleNode("//q1:numberofemployees").nodeTypedValue;
}
}
Неужели никак нельзя это реализовать?
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Где найти веб-форму Преобразования интереса? Impulse Dynamics CRM: Разработка 2 28.09.2008 13:55
Ошибка при создании веб-ссылки в MS VS? Alexey-IT Dynamics CRM: Разработка 1 12.01.2008 03:24
Через веб не отображается полученная почта Hungrymar Dynamics CRM: Администрирование 14 19.12.2006 10:09
Не могу отправить почту через веб-интерфейс Hungrymar Dynamics CRM: Администрирование 0 18.11.2006 09:44
Ошибки в веб интерфесе DiMish Dynamics CRM: Администрирование 5 29.11.2005 17:50

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 14:09.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.