Answered by:
Need help with web form?!?! CRM 2013

Question
-
Hello,
We are just a few steps away from releasing our new CRM system to the office. I have tried to work with 3 different companies on this and I can not find one who will help they all want a project or for us to buy some integration plugin.
All I am trying to do is create a public facing webpage that can query some account information and display it on a webform. I do NOT have the GUID yet it will need to be able to look the record up by account number. I know there are a number of ways to connect to CRM but I can not seam to figure out the right way in a webpage that lets me do what I need it to. The SDK examples create a record then use the GUID from that record to update/retrieve data.
I have tried with the following guide but it does not have query abilities: http://social.microsoft.com/Forums/en-US/f16384a5-ade6-47a7-9790-061630b55178/ms-crm-2011-create-contact
FYI: This is CRM 2013 On-Premise
Thanks!
Ryan
- Edited by Ryan Gergen Thursday, March 20, 2014 8:15 PM Update info
Thursday, March 20, 2014 8:04 PM
Answers
-
Hopefully the example I sent helps!
Jason Lattimer
My Blog - Follow me on Twitter - LinkedIn- Marked as answer by Ryan Gergen Friday, March 21, 2014 2:18 PM
Thursday, March 20, 2014 9:58 PMModerator
All replies
-
I'd look at the Solution - \SDK\SampleCode\CS\QuickStart\QuickStartCS - it has examples on connecting to CRM.
You can look at the Solution - \SDK\SampleCode\CS\GeneralProgramming\Queries\Query - specifically QueryByAttribute. This would allow you to search by a field property.
Jason Lattimer
My Blog - Follow me on Twitter - LinkedIn- Proposed as answer by JLattimerMVP, Moderator Thursday, March 20, 2014 8:16 PM
Thursday, March 20, 2014 8:16 PMModerator -
Jason,
I have maybe I am just not understanding. or maybe it is my slight lack of C# knowledge.
Also FYI Jason we purchased CRM from your company. I have had a hell of a time getting help from them without the need for a huge contracted project.
Thanks,
Ryan
Thursday, March 20, 2014 8:19 PM -
Hopefully the example I sent helps!
Jason Lattimer
My Blog - Follow me on Twitter - LinkedIn- Marked as answer by Ryan Gergen Friday, March 21, 2014 2:18 PM
Thursday, March 20, 2014 9:58 PMModerator -
Hi
What is your struggle?
Is this serverside ASP.NET? Are you Online, On-Premise / IFD?
Is it the connection to CRM or the Query/Request that is the problem?
For query to CRM using strong typing with a generated entity-class use this:
("client" in the code is the organizationservice object)
string accountnumber = "11111"; OrganizationServiceContext osc=new OrganizationServiceContext(client); //list of accounts var account = osc.CreateQuery<Account>().Where(acc => acc.AccountNumber == accoutnumber); //One account or null (error if more than one) var oneaccount = osc.CreateQuery<Account>().SingleOrDefault(acc => acc.AccountNumber == accoutnumber);
If you have no entites file, use this:
string accoutnumber = "11111"; OrganizationServiceContext osc=new OrganizationServiceContext(client); //list of accounts var account = osc.CreateQuery("account").Where(acc => acc.GetAttributeValue<string>("accountnumber") == accoutnumber); //One account or null (error if more than one) var oneaccount = osc.CreateQuery("account").SingleOrDefault(acc => acc.GetAttributeValue<string>("accountnumber") == accoutnumber);
In both cases you need the following references from the crm SDK in your web project
microsoft.crm.sdk.proxy
microsoft.xrm.sdk
microsoft.xrm.client
Best Regards Jens Egil Evensen
- Edited by Jens Egil Evensen [CGI] Friday, March 21, 2014 1:22 PM
- Proposed as answer by Jens Egil Evensen [CGI] Friday, March 21, 2014 1:22 PM
Friday, March 21, 2014 1:10 PM