2011-06-14 146 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

相關問題