Нужен необработанный xml для запроса PropagateByExpression для MS Dynamics CRM - PullRequest
1 голос
/ 02 апреля 2020

Мне нужна небольшая помощь.

В MS Dynamics CRM есть запрос - PropagateByExpressionRequest. Его цель - создать QuickCampaign. Вот пример для C#:

MSDN :

// create the bulkoperation
PropagateByExpressionRequest request = new PropagateByExpressionRequest() {
    Activity = emailActivityEntity,
    ExecuteImmediately = false, // Default value.
    FriendlyName = "Query Based Quick Campaign",
    OwnershipOptions = ownershipOption,
    QueryExpression = query,
    Owner = new EntityReference("systemuser", _currentUser),
    PostWorkflowEvent = true,
    SendEmail = false,
    TemplateId = Guid.Empty
};

Дело в том, что мы используем Java, и мне нужен необработанный XML - Пример этого запроса, но я не смог его найти.

Если кто-то знает, как он выглядит или как его получить - пожалуйста, помогите. :)

Редактировать 1 : версия CRM 2015.

Редактировать 2 : Пример (вопрос об имени, формате атрибутов):

<s:Envelope
    xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services"
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts"
    xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic"
    xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:c="http://www.w3.org/2001/XMLSchema"
>
  <s:Body>
    <Execute>
      <request i:type="a:PropagateByExpressionRequest">
        <a:Parameters>
          <a:KeyValuePairOfstringanyType>
            <b:key>FriendlyName</b:key>
            <b:value i:type="c:string">Query Based Quick Campaign</b:value>
          </a:KeyValuePairOfstringanyType>
          <a:KeyValuePairOfstringanyType>
            <b:key>ExecuteImmediately</b:key>
            <b:value i:type="c:boolean">true</b:value>
          </a:KeyValuePairOfstringanyType>
          <a:KeyValuePairOfstringanyType>
            <b:key>Activity</b:key>
            <b:value i:type="a:Entity">
              <a:KeyValuePairOfstringanyType>
                <b:key>activityid</b:key>
                <b:value i:type="c:string">00000000-0000-0000-0000-000000000000</b:value>
              </a:KeyValuePairOfstringanyType>
            </b:value>
          </a:KeyValuePairOfstringanyType>
          <a:KeyValuePairOfstringanyType>
            <b:key>TemplateId</b:key>
            <b:value i:type="a:EntityReference">
              <a:Id>00000000-0000-0000-0000-000000000000</a:Id>
              <a:LogicalName>phonecall</a:LogicalName>
              <a:Name></a:Name>
            </b:value>
          </a:KeyValuePairOfstringanyType>
          <a:KeyValuePairOfstringanyType>
            <b:key>OwnershipOptions</b:key>
            <b:value i:type="c:integer">1</b:value>
          </a:KeyValuePairOfstringanyType>
          <a:KeyValuePairOfstringanyType>
            <b:key>PostWorkflowEvent</b:key>
            <b:value i:type="c:boolean">true</b:value>
          </a:KeyValuePairOfstringanyType>
          <a:KeyValuePairOfstringanyType>
            <b:key>Owner</b:key>
            <b:value i:type="a:EntityReference">
              <a:Id>00000000-0000-0000-0000-000000000000</a:Id>
              <a:LogicalName>systemuserid</a:LogicalName>
              <a:Name></a:Name>
            </b:value>
          </a:KeyValuePairOfstringanyType>
          <a:KeyValuePairOfstringanyType>
            <b:key>SendEmail</b:key>
            <b:value i:type="c:boolean">false</b:value>
          </a:KeyValuePairOfstringanyType>
        </a:Parameters>
        <a:RequestId>00000000-0000-0000-0000-000000000000</a:RequestId>
        <a:RequestName>PropagateByExpression</a:RequestName>
      </request>
    </Execute>
  </s:Body>
</s:Envelope>

1 Ответ

0 голосов
/ 02 апреля 2020

SOAP конечная точка устарела, и у нас есть веб-API REST - поэтому мы можем использовать действие PropagateByExpression. Подробнее

Пример кода будет выглядеть следующим образом: (Извините, я не из Java фона, но я знаю Javascript)

var parameters = {};
parameters.FriendlyName = "Query Based Quick Campaign";
parameters.ExecuteImmediately = false;
var activity = {};
activity.activityid = "00000000-0000-0000-0000-000000000000"; //Delete if creating new record 
activity["@odata.type"] = "Microsoft.Dynamics.CRM.email";
parameters.Activity = activity;
parameters.TemplateId = "00000000-0000-0000-0000-000000000000";
parameters.OwnershipOptions = ownershipOption;
parameters.PostWorkflowEvent = true;
var owner = {};
owner.systemuserid = "00000000-0000-0000-0000-000000000000"; //Delete if creating new record 
owner["@odata.type"] = "Microsoft.Dynamics.CRM.systemuser";
parameters.Owner = owner;
parameters.SendEmail = false;

var req = new XMLHttpRequest();
req.open("POST", "https://devcrmorgname.crm.dynamics.com/api/data/v9.1/PropagateByExpression", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
    if (this.readyState === 4) {
        req.onreadystatechange = null;
        if (this.status === 200) {
            var results = JSON.parse(this.response);
        } else {

        }
    }
};
req.send(JSON.stringify(parameters));
...