【问题标题】:creating a contact and updating a custom field MSCRM 4创建联系人并更新自定义字段 MSCRM 4
【发布时间】:2010-07-13 07:41:43
【问题描述】:

这是我的代码示例...

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# 创建一个联系人,并且我创建了所有基本字段,而不是自定义字段。

谢谢

【问题讨论】:

    标签: c# dynamics-crm dynamics-crm-4


    【解决方案1】:

    您正在使用自动生成的服务参考。每当您对 CRM 中的实体进行(并发布)更改时,更新 V​​isual Studio 中的服务引用。

    【讨论】:

    • 为避免不断更新服务引用,您也可以只使用 DynamicEntity 对象并以这种方式进行更新。
    • 确实.. 缺点只是你失去了强类型。但优点是灵活性更高,并且能够抽象出在常见 DynamicEntity 上运行的某些功能。
    【解决方案2】:

    右键单击解决方案资源管理器中 Web 服务下的引用,然后单击“更新 Web 引用”。现在应该可以使用自定义选项了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-13
      • 2018-05-17
      • 1970-01-01
      • 2023-04-01
      • 2016-09-05
      • 1970-01-01
      相关资源
      最近更新 更多