CRMからデータを取得しています。私はquotedetail
からいくつかのフィールドを取得したいです。そのうちの1つはint
フィールドad_discountpercent
です。データが取得されていることを確認する - CRM
このフィールドには値は必要ありません。
値がない場合は、そのフィールドから値を取得し、デフォルト値の0
を付ける必要があります。ここで
は私のコードです:
string fetch1 = @"
<fetch count='50' >
<entity name='quotedetail' >
<attribute name='manualdiscountamount' />
<attribute name='priceperunit' />
<attribute name='ad_discountpercent' />
<attribute name='quantity' />
<attribute name='extendedamount' />
</entity>
</fetch>";
EntityCollection result = service.RetrieveMultiple(new FetchExpression(fetch1));
foreach (var c in result.Entities)
{
if(...)
}
私が見て(...)
の代わりに何を置くべき任意のデータを検索し、デフォルト値を与えることがありますか?あなたが知っていれば、この2つのことを知っていると助けになるでしょう。
追加情報が必要な場合はお知らせください。あなたがあなたのケースではGetAttributeValue<T>(string attribute logical name)
を使用することができ、フィールドの値にアクセスするには
結果の種類は? –
<>カッコ内の内容によって異なります。私は 'c.GetAttributeValue(" ad_discountpercent ")' :) –
Nick