Take the 2-minute tour ×

i developed CMS to one of my customers and he wants that when a user fill in the contact form, it will automatically generate lead in his CRM. what is the easiest way to do that?

by the way, the contact form is ajax and the data is transfered to asmx, so it will be easy to call to CRM webservice or something like that, because i'm already in the server side.

can someone point me to tutorial or some code example? thanks!

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Your best start will be with the SDK available here, which contains example code and the sdk dlls etc...

Here is a page with a quick reference to all the web service endpoints available in the different flavors of CRM 2011.

From the SDK samplepcode\cs\quickstart creating account, but very similar for lead:

            // Connect to the Organization service. 
            // The using statement assures that the service proxy will be properly disposed.
            using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri,
                _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

                // Instaniate an account object.
                // See the Entity Metadata topic in the SDK documentation to determine 
                // which attributes must be set for each entity.
                Account account = new Account { Name = "Fourth Coffee" };

                // Create an account record named Fourth Coffee.
                _accountId = _serviceProxy.Create(account);
                Console.Write("{0} {1} created, ", account.LogicalName, account.Name);

                // Retrieve the account containing several of its attributes.
                ColumnSet cols = new ColumnSet(
                    new String[] { "name", "address1_postalcode", "lastusedincampaign" });

                Account retrievedAccount = (Account)_serviceProxy.Retrieve("account", _accountId, cols);
                Console.Write("retrieved, ");

                // Update the postal code attribute.
                retrievedAccount.Address1_PostalCode = "98052";

                // The address 2 postal code was set accidentally, so set it to null.
                retrievedAccount.Address2_PostalCode = null;

                // Shows use of a Money value.
                retrievedAccount.Revenue = new Money(5000000);

                // Shows use of a boolean value.
                retrievedAccount.CreditOnHold = false;

                // Update the account record.
                Console.WriteLine("and updated.");
share|improve this answer
thanks, i started to read the SDK, i thought maybe someone did the same task before (i guess lot of people need that functionality) and can share some code or some tutorial. –  eran Jun 13 '11 at 23:35
Updated the answer with some specific code examples available in the SDK –  csjohnst Jun 14 '11 at 3:38
thanks, that really helps. –  eran Jun 14 '11 at 8:11
add comment

Your Answer


