简体   繁体   中英

Microsoft dynamics CRM 2011: how to generate lead from external contact form

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!

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,
                                                                serverConfig.HomeRealmUri,
                                                                serverConfig.Credentials,
                                                                serverConfig.DeviceCredentials))
            {
                // This statement is required to enable early-bound type support.
                _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.
                _serviceProxy.Update(retrievedAccount);
                Console.WriteLine("and updated.");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM