答えて

1

あなたは代わりにカスタムワークフローのPluginを使用し、「検索」のメッセージでそれを登録することができます。

public void Execute(IServiceProvider serviceProvider) 
{ 
// Obtain the execution context from the service provider. 
Microsoft.Xrm.Sdk.IPluginExecutionContext context = (Microsoft.Xrm.Sdk.IPluginExecutionContext) 
    serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext)); 

if (context.Depth == 1) 
{ 
    IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); 
    IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); 

    // Obtain the target entity from the input parmameters. 
    EntityReference entity = (EntityReference)context.InputParameters["Target"]; 

    ColumnSet cols = new ColumnSet(
         new String[] { "lastname", "firstname", "address1_name" }); 

    var contact = service.Retrieve("contact", entity.Id, cols); 

    if (contact != null) 
    { 
     if (contact.Attributes.Contains("address1_name") == false) 
     { 
      Random rndgen = new Random(); 
      contact.Attributes.Add("address1_name", "first time value: " + rndgen.Next().ToString()); 
     } 
     else 
     { 
      contact["address1_name"] = "i already exist"; 
     } 
     service.Update(contact); 
    } 
    } 
} 

enter image description here

CRM 2011–Retrieve Plugin

2

カスタムワークフローアクティビティをトリガしたいしていて、その中のワークフロー関連何もする必要がない場合、私はカスタムアクションを作成することをお勧めしたいです。これはワークフローと非常によく似ていますが、CRMはあなたに電話するカスタムエンドポイントを作成します。ワークフローIDを追跡する必要がなくなります。

関連する問題