crm 2011 で複数のフェッチを含むスクリプトでエラーが発生しました...エラーは、キーが存在しないことと、次のものから来ていることです。
<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);
}
ありがとう :)