Dynamics365CE 工作流程:检查值是否已存在并更新记录

Dynamics365CE workflow: check if value already exists and update record

当用户打开一个新案例时,我需要检查新案例的序列号是否已经存在,以便更改案例的优先级。我使用 Kaskela 的解决方案来执行此操作,我认为最好的方法是使用查询来获取单个值(我实际上想要获取的是 true 或 false 布尔值)

这是我使用的 fetchXML

<fetch mapping='logical'>
  <entity name='case'>
   <attribute name='title'/>
     <filter type='and'>
        <condition attribute='abc_serialnumber' operator='eq' value='DYN_serialnumber' />
     </filter>       
  </entity>    
</fetch> 

我收到错误

An exception System.FormatException was thrown while trying to convert input value 'SN00105GH' to attribute 'case.abc_serialnumber'. Expected type of attribute value: System.Guid. Exception raised: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

我知道它需要序列号的 GUID,但我不能使用它,因为它在另一个实体中。

我有两个问题: 查询获取单个值是实现我想要的正确方法吗? 为什么需要 GUID?

我的理解是,abc_serialnumber 是对案例记录的查找,因此它始终是一个 GUID - 32 位数字和 4 个破折号 (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。您作为 DYN_serialnumber 传递的值是 SN00105GH,但系统无法进行此比较 - 带有字符串的 GUID。因此错误。

如果您始终知道该值(即 SN00105GH),那么您必须根据此值从 abc_serialnumber 实体中进行另一次提取,然后将检索到的序列号记录 GUID 传递到您的上面询问。这将为您提供与指定序列号相关联的案例 wrt 传递值。

否则,您必须在 fetchxml 中执行链接实体,以便在单个查询中将案例与按值过滤的序列号连接起来。

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" >
  <entity name="case" >
    <attribute name="title" />
    <link-entity name="abc_serialnumber" from="abc_serialnumber" to="abc_serialnumberid" link-type="inner" alias="ac" >
      <filter type="and" >
        <condition attribute="abc_name" operator="like" value="SN00105GH" />
      </filter>
    </link-entity>
  </entity>
</fetch>

如果查询的查询结果计数大于零,则结果为真。否则为假。