ochangc
asked on
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
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.
The code I sent is for 3.0 and will not work with 4.0.
ASKER
Ok, this is all good. now how do i post this to a grid to view?
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.
ASKER
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.
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.BusinessEntiti es.Length > 0)
{
List<Account> accounts = new List<Account>();
foreach(accountRecord in collection.BusinessEntitie s.Business Entities)
{
Account accountInstance = new Account{Name = accountRecord.name};
accounts.Add(accountInstan ce);
}
gridView.DataSource = accounts;
gridView.AutoGenerateColum ns = true;
gridView.DataBind();
}
// DTO to mimic CRM entity
class Account
{
public string Name {get; set;}
}
if (collection.BusinessEntiti
{
List<Account> accounts = new List<Account>();
foreach(accountRecord in collection.BusinessEntitie
{
Account accountInstance = new Account{Name = accountRecord.name};
accounts.Add(accountInstan
}
gridView.DataSource = accounts;
gridView.AutoGenerateColum
gridView.DataBind();
}
// DTO to mimic CRM entity
class Account
{
public string Name {get; set;}
}
ASKER
This is what I get
An exception of type 'System.Web.Services.Proto cols.SoapE xception' 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.E xecute(att ributeRequ est);
And when I add an exception handler it says
server was unable to handle request
Helllp!
An exception of type 'System.Web.Services.Proto
Additional information: Server was unable to process request.
It happens right on this line
RetrieveAttributeResponse attributeResponse = (RetrieveAttributeResponse
And when I add an exception handler it says
server was unable to handle request
Helllp!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.