2011-06-14 179 views
0

我已经写在类库代码后,我没有建立的代码,复制代码 C:\Program Files\Microsoft Dynamics CRM\Server\bin\assembly通过在Microsoft Dynamics使用插件CRM

我试图添加一个数值来考虑实体的销售代表属性模拟工作。它没有填充表单中的值。

任何人都可以帮我解决这个问题吗?

public void Execute(IPluginExecutionContext context) 
{ 
    DynamicEntity entity = null; 

    if (context.InputParameters.Properties.Contains("Target") && 
     context.InputParameters.Properties["Target"] is DynamicEntity) 
    { 
     entity = (DynamicEntity)context.InputParameters.Properties["Target"]; 
     if (entity.Name != EntityName.account.ToString()) { return; } 
    } 
    else 
    { 
     return; 
    } 

    try 
    { 
     // DynamicEntity followup = new DynamicEntity(); 
     CrmNumber gcs_numb = new CrmNumber(); 
     gcs_numb.Value = 10; 
     //follow.Properties = new PropertyCollection(); 
     entity.Properties.Add(new CrmNumberProperty("gcs_numberofsalesreps", gcs_numb)); 
    } 
    catch (System.Web.Services.Protocols.SoapException ex) 
    { 
     throw new InvalidPluginExecutionException(
       "An error occurred in the Account plug-in.", ex); 
    } 
} 

回答

1

这可能是一些东西,我会恳请更多的一些信息:

你是怎么注册的插件?通常情况下,您希望在事件即创建时同步注册。使用Plugin Registration Tool

您是否忽略致电ICrmService.Update

ICrmService service = context.CreateCrmService(true); 
service.Update(entity); 

有您创建自定义字段,并把它们正确地发布? * gcs_numberofsalesreps *必须作为帐户实体上的有效数字字段存在。

+0

根据消息和阶段,不需要显式更新,因为您可以更改直接处理的记录。 – ccellar 2011-06-15 13:38:07

相关问题