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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 11.04.2012, 15:18   #1  
Kipetcoff is offline
Kipetcoff
Участник
 
136 / 16 (1) ++
Регистрация: 20.05.2009
Адрес: Санкт-Петербург
Close Opportunity
Добрые день, коллеги. Не пишется значение в поле actualrevenue во время закрытия OpportunityClose в CRM 2011

Запрос вот

Код:
var requestMain = "";
        requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
        requestMain += "  <s:Body>";
        requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
        requestMain += "      <request i:type=\"b:WinOpportunityRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
        requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
        requestMain += "          <a:KeyValuePairOfstringanyType>";
        requestMain += "            <c:key>OpportunityClose</c:key>";
        requestMain += "            <c:value i:type=\"a:Entity\">";
        requestMain += "              <a:Attributes>";
        requestMain += "                <a:KeyValuePairOfstringanyType>";
        requestMain += "                  <c:key>opportunityid</c:key>";
        requestMain += "                  <c:value i:type=\"a:EntityReference\">";
        requestMain += "                    <a:Id>" + opportunityid + "</a:Id>";
        requestMain += "                    <a:LogicalName>opportunity</a:LogicalName>";
        requestMain += "                    <a:Name i:nil=\"true\" />";
        requestMain += "                  </c:value>";
        requestMain += "                </a:KeyValuePairOfstringanyType>";
        requestMain += "                <a:KeyValuePairOfstringanyType>";
        requestMain += "                  <c:key>subject</c:key>";
        requestMain += "                  <c:value i:type=\"d:string\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">" + subject + "</c:value>";
        requestMain += "                </a:KeyValuePairOfstringanyType>";
        requestMain += "                <a:KeyValuePairOfstringanyType>";
        requestMain += "                  <c:key>description</c:key>";
        requestMain += "                  <c:value i:type=\"d:string\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">" + desctiption + "</c:value>";
        requestMain += "                </a:KeyValuePairOfstringanyType>";
        requestMain += "                <a:KeyValuePairOfstringanyType>";
        requestMain += "                  <c:key>actualend</c:key>";
        requestMain += "                  <c:value i:type=\"g:dateTime\" xmlns:g=\"http://www.w3.org/2001/XMLSchema\">" + actualend.format("isoUtcDateTime") + "</c:value>";
        requestMain += "                </a:KeyValuePairOfstringanyType>";
        requestMain += "                <a:KeyValuePairOfstringanyType>";
        requestMain += "                  <c:key>actualrevenue</c:key>";
        requestMain += "                  <c:value i:type=\"e:decimal\" xmlns:e=\"http://www.w3.org/2001/XMLSchema\">123.00</c:value>";
        requestMain += "                </a:KeyValuePairOfstringanyType>";
        requestMain += "              </a:Attributes>";
        requestMain += "              <a:EntityState i:nil=\"true\" />";
        requestMain += "              <a:FormattedValues />";
        requestMain += "              <a:Id>00000000-0000-0000-0000-000000000000</a:Id>";
        requestMain += "              <a:LogicalName>opportunityclose</a:LogicalName>";
        requestMain += "              <a:RelatedEntities />";
        requestMain += "            </c:value>";
        requestMain += "          </a:KeyValuePairOfstringanyType>";
        requestMain += "          <a:KeyValuePairOfstringanyType>";
        requestMain += "            <c:key>Status</c:key>";
        requestMain += "            <c:value i:type=\"a:OptionSetValue\">";
        requestMain += "              <a:Value>" + status + "</a:Value>";
        requestMain += "            </c:value>";
        requestMain += "          </a:KeyValuePairOfstringanyType>";
        requestMain += "        </a:Parameters>";
        requestMain += "        <a:RequestId i:nil=\"true\" />";
        requestMain += "        <a:RequestName>WinOpportunity</a:RequestName>";
        requestMain += "      </request>";
        requestMain += "    </Execute>";
        requestMain += "  </s:Body>";
        requestMain += "</s:Envelope>";
        var req = new XMLHttpRequest();
Сущность OpportunityClose создается, но поле actualrevenue пустое.

Цифирка 123.00 вбита руками для теста и она никак не сохраняется. НИГДЕ не нашел примера чтобы писалось знаение Money в поле. Может я не корректно тип данных пишу, но я уже все возможные перепробовал. Что делать?
Старый 11.04.2012, 15:50   #2  
g.Naukovych is offline
g.Naukovych
Участник
MCBMSS
Лучший по профессии 2014
Лучший по профессии AXAWARD 2013
 
405 / 130 (5) +++++
Регистрация: 23.03.2011
Выполнил следующий код

X++:
            Entity entity = new Entity("test");
            entity["moneyfield"] = new Money(new Decimal(123));
            DataContractSerializer serializer = new DataContractSerializer(typeof(Entity), "entity", @"http://schemas.microsoft.com/xrm/2011/Contracts/Services");
            MemoryStream ms = new MemoryStream();
            StringWriter sw = new StringWriter();
            using (XmlTextWriter writer = new XmlTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;
                serializer.WriteObject(writer, entity);
            }

            string aaa =  sw.ToString();
Результат выполнения следующий:

X++:
 <entity xmlns:d1p1="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
 <d1p1:Attributes xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
  <d1p1:KeyValuePairOfstringanyType>
  	<d2p1:key>moneyfield</d2p1:key> 
	  <d2p1:value i:type="d1p1:Money">
	  	<d1p1:Value>123</d1p1:Value> 
          </d2p1:value>
  </d1p1:KeyValuePairOfstringanyType>
  </d1p1:Attributes>
  <d1p1:EntityState i:nil="true" /> 
  <d1p1:FormattedValues xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" /> 
  <d1p1:Id>00000000-0000-0000-0000-000000000000</d1p1:Id> 
  <d1p1:LogicalName>test</d1p1:LogicalName> 
  <d1p1:RelatedEntities xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" /> 
  </entity>
Думаю
это Вам поможет.

X++:
 <d1p1:KeyValuePairOfstringanyType>
  	<d2p1:key>moneyfield</d2p1:key> 
	  <d2p1:value i:type="d1p1:Money">
	  	<d1p1:Value>123</d1p1:Value> 
          </d2p1:value>
  </d1p1:KeyValuePairOfstringanyType>
Если и это не получилось, то создайте объект, заполните его руками, и сериализуйте. Получите точно правильный XML, хотя я думаю все и так будет работать.
__________________
Мой блог https://procrm.tv

Последний раз редактировалось g.Naukovych; 11.04.2012 в 15:55.
За это сообщение автора поблагодарили: Kipetcoff (1).
Старый 11.04.2012, 16:15   #3  
Kipetcoff is offline
Kipetcoff
Участник
 
136 / 16 (1) ++
Регистрация: 20.05.2009
Адрес: Санкт-Петербург
Да, так работает!
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Muhammad Ali Khan: Close Service Activity On Create Message In PlugIn Blog bot Dynamics CRM: Blogs 0 19.02.2010 23:05
a33ik: Custom workflow action which returns Opportunity Close object based on Opportunity object Blog bot Dynamics CRM: Blogs 0 11.02.2010 15:05
a33ik: Making Description Field Required in Close Opportunity Dialog Blog bot Dynamics CRM: Blogs 0 10.02.2010 00:07
Как зарегистрировать plugin на opportunity SVK Dynamics CRM: Разработка 2 09.10.2009 19:44
Close opportunity Kipetcoff Dynamics CRM: Разработка 2 16.06.2009 15:19

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

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

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