web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to create a record in contact using silverlight form in CRM 2013 c# code?

(0) ShareShare
ReportReport
Posted on by

Hi,

 Can any one help me to create a record in contact using silverlight form in CRM 2013 c# code?

Thanks

*This post is locked for comments

I have the same question (0)
  • Aileen Gusni Profile Picture
    44,524 on at

    Hi Habeeb,

    This is the sample code I did using Silverlight before:

    private void CreateCustomer()
            {
                try
                {

                    Contact contactRecord = new Contact();

                    contactRecord.FirstName = txtFirstName.Text;
                    contactRecord.LastName = txtLastName.Text;
                    contactRecord.FullName = txtFirstName.Text + txtLastName.Text;

                    OptionSetValue osvGender = new OptionSetValue();
                    if (rbGenderMale.IsChecked == true)
                    {
                        osvGender.Value = 1;
                    }
                    else
                    {
                        osvGender.Value = 2;
                    }
                    contactRecord.GenderCode = osvGender;

                    if (rbReceivePromoSMSYes.IsChecked == true)
                    {
                        contactRecord.new_ReceivePromoSMS = true;
                    }
                    else
                    {
                        contactRecord.new_ReceivePromoSMS = false;
                    }

                    contactRecord.MobilePhone = txtMobilePhone.Text;
                    contactRecord.EMailAddress1 = txtEmail.Text;
                    contactRecord.Address1_Telephone1 = txtPhone.Text;
                    contactRecord.Address1_Name = txtAddressName.Text;
                    contactRecord.Address1_Line1 = txtStreet1.Text;
                    contactRecord.Address1_Line2 = txtStreet2.Text;
                    contactRecord.Address1_City = txtCity.Text;
                    contactRecord.Address1_StateOrProvince = txtProvince.Text;
                    contactRecord.Address1_Country = txtCountry.Text;
                    contactRecord.Address1_PostalCode = txtPostalCode.Text;

                    _context.AddToContactSet(contactRecord);
                    _context.BeginSaveChanges(OnCreateCustomerComplete, contactRecord);
                }
                catch (SystemException se)
                {
                    MessageBox.Show(se.Message);
                }
            }

            private void OnCreateCustomerComplete(IAsyncResult result)
            {
                try
                {
                    _context.EndSaveChanges(result);
                    Contact contactRecord = result.AsyncState as Contact;

                    txtStatus.Text = "Customer " + contactRecord.FullName + " has been created...";
                }
                catch (SystemException se)
                {
                    MessageBox.Show(se.Message);
                }
            }

    Hope it helps!

  • Aileen Gusni Profile Picture
    44,524 on at

    You might refer to these links:

    arvindcsit.wordpress.com/.../create-crm-records-using-rest-endpoint-with-silverlight

    crmallied.blogspot.com/.../silverlight-create-update-delete_13.html

    Silverlight also using REST Endpoint method, you might to download the CSDL file.

  • Habeeb-Dynamics CRM Application Developer Profile Picture
    on at

    Hi Aileen Gusni,

     While adding a value to attribute in Contact Entity i am getting an error as shown in below picture.

    My aim is to create a record in contact entity using silverlight application.


     

    Thank You.

  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at

    Hi Habeeb,

    You need to add reference another .cs

    blogs.msdn.com/.../silvercrmsoap-a-crm-soap-library-for-crm-2011.aspx

    msdn.microsoft.com/.../gg594452.aspx

    Silverlight in CRM 2013 it is almost deprecated but you still can use it.

    Hope this helps!

    Thanks.

  • Verified answer
    Habeeb-Dynamics CRM Application Developer Profile Picture
    on at

    could you plz help me, how can i create a record using silverlight in CRM2013.And where would i find another.cs file for reference.

    Silverlight in CRM 2013 it is almost deprecated???

    Thanks

  • Aileen Gusni Profile Picture
    44,524 on at

    Hi Habeeb,

    Please see the answer.

    I gave you the links, I gave you the sample codes of mine.

    What else you need? 

  • Habeeb-Dynamics CRM Application Developer Profile Picture
    on at

    Thank you for your code.But the links you have sent me that is only for 2011 CRM. Again i made some changes in that code but i can't create a record.

  • Aileen Gusni Profile Picture
    44,524 on at

    What is the error now?

    I still can use that in my CRM 2013

    Why you don't change to Web Resource HTML5

  • Habeeb-Dynamics CRM Application Developer Profile Picture
    on at

    _context.AddToContactSet(contactRecord);

    _context.BeginSaveChanges(OnCreateCustomerComplete, contactRecord);

    error at above lines.I have added a ServiceUtility.cs file and SilverlightExtensionMethods.cs again it is showing that context doesn't contain a method AddToContactSet(contactRecord);.

    BeginSaveChanges(OnCreateCustomerComplete, contactRecord);.......And i am going to change it to Html5.

    Thank You Aileen Gusni for you patience.

  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at

    What context did you use.

    You should generate an early bound library, in this case service reference

    So that, see this link in the CSDL section:

    arvindcsit.wordpress.com/.../create-crm-records-using-rest-endpoint-with-silverlight

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans