Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Loop through a WebApi Result

$
0
0

Anytime, I try to loop the WebAPI(Json result), I always get the first value in the api printed the number of count of the result.

If I have 50 results in the Web Api query the first company(eg. ABC Corp) will be printed 50x. 

Here is a sample code below, I am using to test from https://github.com/davidyack/Xrm.Tools.CRMWebAPI/tree/master/dotnet:

string fetchXml = "<fetch mapping='logical'><entity name='account'><attribute name='accountid'/><attribute name='name'/></entity></fetch>";

var fetchResults = await api .Result.Item2.GetList("accounts", QueryOptions: new CRMGetListOptions() { FetchXml = fetchXml });

foreach (var record in fetchResults.List){
      foreach (var account in record){
         _accountRecord.accountIdNumber = account.Value.ToString();
         _account.Add(_accountRecord);
                             }
                     }

I would like to be able to pint out each company/account name our DynamicsCrmOnline.


Thank you in advance,


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>