我在 crm 2011 中包含多个 fetch 的脚本出现错误...错误是密钥存在并且来自:
<condition attribute='bc_type' operator='eq' lable='Credit' value='948110001' />
如果没有记录存在条件它失败,而不是只是传递并返回 0 任何想法?
我声明
decimal TotalDed = 0;
decimal TotalCre = 0;
编码:
string value_sum = string.Format(@"
<fetch distinct='false' mapping='logical' aggregate='true'>
<entity name='bc_llbalance'>
<attribute name='bc_units' alias='ded_sum' aggregate='sum' />
<filter type='and'>
<condition attribute='bc_learninglicense' operator='eq' value='{0}' uiname='' uitype='' />
<condition attribute='bc_type' operator='eq' lable='Deduction' value='948110000' />
</filter>
</entity>
</fetch>", a);
EntityCollection value_sum_result = service.RetrieveMultiple(new FetchExpression(value_sum));
foreach (var b in value_sum_result.Entities)
{
TotalDed = ((Decimal)((AliasedValue)b["ded_sum"]).Value);
}
string cre_sum = string.Format(@"
<fetch distinct='false' mapping='logical' aggregate='true'>
<entity name='bc_llbalance'>
<attribute name='bc_units' alias='cre_sum' aggregate='sum' />
<filter type='and'>
<condition attribute='bc_type' operator='eq' lable='Credit' value='948110001' />
<condition attribute='bc_learninglicense' operator='eq' value='{0}' uiname='' uitype='' />
</filter>
</entity>
</fetch>", a);
EntityCollection cre_sum_result = service.RetrieveMultiple(new FetchExpression(cre_sum));
foreach (var c in cre_sum_result.Entities)
{
TotalCre = ((Decimal)((AliasedValue)c["cre_sum"]).Value);
}
谢谢 :)