views:

31

answers:

2

Hello,

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

+3  A: 

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.

PjL
To avoid having to constantly update your service reference, you can also just use DynamicEntity objects and do your updates that way.
Matt
Indeed.. the downside just being that you lose the strong typing.. but the upside is a lot more flexibility, and the ability to abstract certain functionality that operates on the common DynamicEntity.
PjL
A: 

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

Jeff Davis