• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 666
  • Last Modified:

retrieving CRM 4 data

I am new to microsoft CRM. I have been able to connect froman aspx page that I created, I now need to populate a grid with CRM data. What is the  best mmethod for this
0
ochangc
Asked:
ochangc
  • 5
  • 3
1 Solution
 
Chinmay PatelEnterprise ArchitectCommented:
Hi cmm4,

I suggest you download CRM SDK from : http://www.microsoft.com/downloadS/details.aspx?FamilyID=82e632a7-faf9-41e0-8ec1-a2662aae9dfb

One of the most common method is listed here : http://technet.microsoft.com/en-us/library/aa680437.aspx

There are two other methods which you might want to check in SDK apart from QueryByExpression
they are:
1. FetchXml
2. QueryByAttribute

I recommend you start with QueryByExpression first and then move further.

Let me know if you have any questions on the same.

Regards,
Chinmay.
0
 
Chinmay PatelEnterprise ArchitectCommented:
Kindly refer to : http://msdn.microsoft.com/en-us/library/bb929002.aspx
The code I sent is for 3.0 and will not work with 4.0.
0
 
ochangcAuthor Commented:
Ok, this is all good. now how do i post this to a grid to view?
0
Put Machine Learning to Work--Protect Your Clients

Machine learning means Smarter Cybersecurity™ Solutions.
As technology continues to advance, managing and analyzing massive data sets just can’t be accomplished by humans alone. It requires huge amounts of memory and storage, as well as the high-speed power of the cloud.

 
Chinmay PatelEnterprise ArchitectCommented:
Once you get results back from CRM you can loop through the resultant BusinessEntityCollection and either create a dataset or bettter a List<T> or a custom array. Once that is done you can bind it to the gridview by setting gridview's datasource property.
0
 
ochangcAuthor Commented:
Thanks, could you post an example. I have been trying all sorts of things and I am spent. The powers to be are need happy in the least. Once again thanks.
0
 
Chinmay PatelEnterprise ArchitectCommented:
Here is a ... pseudo code not sure whether it will compile or not, but this is to give you an idea, you can process the data in many ways.


 if (collection.BusinessEntities.Length > 0)
            {
            List<Account> accounts = new List<Account>();
            foreach(accountRecord in collection.BusinessEntities.BusinessEntities)
            {
                      Account accountInstance = new Account{Name = accountRecord.name};
                  accounts.Add(accountInstance);
            }
            
            gridView.DataSource = accounts;
            gridView.AutoGenerateColumns = true;
            gridView.DataBind();                            

            }

// DTO to mimic CRM entity
class Account
{
public string Name {get; set;}
}
0
 
ochangcAuthor Commented:
This is what I get

An exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll but was not handled in user code

Additional information: Server was unable to process request.

It happens right on this line
   RetrieveAttributeResponse attributeResponse = (RetrieveAttributeResponse)service.Execute(attributeRequest);
And when I add an exception handler it says
server was unable to handle request

Helllp!
0
 
Chinmay PatelEnterprise ArchitectCommented:
This is not the code we were trying out... what exactly you are doing? Also for SoapException originated from CRM you should check its Details.InnerText.
0

Featured Post

2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now