C# 创建联系人并更新自定义字段MSCRM 4
这是我的代码示例C# 创建联系人并更新自定义字段MSCRM 4,c#,dynamics-crm,dynamics-crm-4,C#,Dynamics Crm,Dynamics Crm 4,这是我的代码示例 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 web
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";
现在问题很简单,我无法访问添加到联系人对象的任何自定义字段。我正在尝试从C#创建联系人,我创建了所有基本字段,但没有自定义字段
谢谢您正在使用自动生成的服务参考。每当您对CRM中的实体进行(并发布)更改时,请在Visual Studio中更新服务引用。在解决方案资源管理器中的“web服务”下的引用上单击鼠标右键,然后单击“更新web引用”。自定义选项现在应可用。为避免不断更新服务引用,您也可以只使用DynamicEntity对象,并以这种方式进行更新。。缺点就是你失去了强大的打字能力。。但好处是灵活性大得多,并且能够抽象出基于公共动态的某些功能。