【问题标题】:Need a raw xml for PropagateByExpressionRequest for MS Dynamics CRM需要用于 MS Dynamics CRM 的 PropagateByExpressionRequest 的原始 xml
【发布时间】:2020-04-02 05:47:34
【问题描述】:

我需要一点帮助。

在 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>

【问题讨论】:

  • 您的意思是 fetchxml 或soap 请求?也分享你的java代码
  • 还有你用的是哪个crm版本?
  • CRM 2015。Java 代码 - 它只是一个带有 SOAP XML 主体的简单 Http-Request (okHttp)。添加了一个示例。

标签: soap dynamics-crm crm


【解决方案1】:

SOAP 端点已被弃用,我们有一个 REST web api - 所以我们可以使用PropagateByExpression Action。 Read more

示例代码如下所示:(抱歉,我不是 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));

【讨论】:

  • 好吧,我们使用的是 CRM 2015,如果我理解正确 - Rest Api 还没有完全到位?
  • @andrewGaara 你是对的。我没有解决这个肥皂难题,而是将 C# 代码放在自定义工作流中,并从 soap 调用中执行工作流。 ankit.inkeysolutions.com/2013/03/…
  • 好的。感谢您的建议。我认为这将是一个解决方案。
  • @andrewGaara 如果我的回答有帮助,请点赞/接受以帮助社区发现它有用..
猜你喜欢
  • 2012-05-21
  • 2016-02-12
  • 1970-01-01
  • 2018-05-02
  • 1970-01-01
  • 2014-02-04
  • 2011-09-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多