Code Smack
Code Smack

Reputation: 163

creating a contact and updating a custom field MSCRM 4

Here is my code sample...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ProjectName.CrmSdk;

//The CrmSdk ref is to the webservice url.

            //ServerName and OrgName are setup in code but not included.
            //standard CRM service setup
            CrmSdk.CrmAuthenticationToken token = new CrmSdk.CrmAuthenticationToken();
            token.AuthenticationType = 0; //AD on premise
            token.OrganizationName = orgName.ToString();
            CrmService service = new CrmService();
            service.Url = "http://" + serverName.ToString() + "/mscrmservices/2007/crmservice.asmx";
            service.CrmAuthenticationTokenValue = token;
            service.Credentials = System.Net.CredentialCache.DefaultCredentials;


            contact c = new contact();

            c.firstname = "joe";
            c.lastname = "Smack";
            //  I can not find or access this custom field when I go to create a contact.
            c.new_customField = "Red Car";

Now the problem is simple, I can not access any of the custom fields I have added to the contact object. I am trying to create a contact from C# and I have all of the base fields created just not the custom ones.

Thank you

Upvotes: 1

Views: 1084

Answers (2)

Jeff Davis
Jeff Davis

Reputation: 4797

Right click on the reference under web services in your solution explorer and click "Update Web Reference." The custom options should now be available.

Upvotes: 0

PjL
PjL

Reputation: 982

You're using the auto-generated service reference. Update the service reference in Visual Studio whenever you've made (and published) changes to your entities in CRM.

Upvotes: 3

Related Questions