|
2 | 2 | title: "Workflow Extensions (Common Data Service) | Microsoft Docs" # Intent and product brand in a unique string of 43-59 chars including spaces
|
3 | 3 | description: "You can extend the options available within the designer for workflows. These extensions are added by adding an assembly that contains a class the extends the CodeActivity class. These extensions are commonly called workflow assemblies or workflow activities." # 115-145 characters including spaces. This abstract displays in the search result.
|
4 | 4 | ms.custom: ""
|
5 |
| -ms.date: 06/12/2019 |
| 5 | +ms.date: 06/20/2019 |
6 | 6 | ms.reviewer: "pehecke"
|
7 | 7 | ms.service: powerapps
|
8 | 8 | ms.topic: "article"
|
@@ -400,6 +400,44 @@ If you make changes that include significant changes to public classes or method
|
400 | 400 |
|
401 | 401 | When all processes are converted to use the new assembly, you can use the Plug-in Registration tool to Unregister the assembly, so it will no longer be available. More information: [Unregister components](../register-plug-in.md#unregister-components)
|
402 | 402 |
|
| 403 | +## Performance Guidance |
| 404 | + |
| 405 | +Performance considerations for your workflow extensions are the same as for ordinary plug-ins. More information: [Performance considerations](../write-plug-in.md#performance-considerations) |
| 406 | + |
| 407 | +Unlike an ordinary plug-in, with workflow extensions you do not have the opportunity to explicitly register your code for a specific step. This means you don't control whether the code in your workflow extension will run synchronously or asynchronously. Particular care must be considered for code that runs synchronously because it will directly impact the application user's experience. |
| 408 | + |
| 409 | +As re-usable components, workflow extensions can be added to any workflow or custom action. The workflow may be configured as a *real-time* workflow, which means it will run synchronously. Custom actions are always synchronous, but they do not participate in a transaction unless they have **Enable rollback** set. |
| 410 | + |
| 411 | +> [!IMPORTANT] |
| 412 | +> When your workflow extension is used in a synchronous workflow or a custom action the time spent running the code directly impacts the user's experience. For this reason, workflow extensions should require no more than two seconds to complete when used synchronously. If your extension requires more time than this, you should document this and discourage use of the extension in synchronous workflows or custom actions. |
| 413 | + |
| 414 | +You should also be aware that in a synchronous workflow or a custom action that that participates in the transaction, any error thrown by your workflow extension will cause the entire transaction to rollback, which is a very expensive operation that can impact performance. |
| 415 | + |
| 416 | +You can use the value in the <xref:Microsoft.Xrm.Sdk.Workflow.IWorkflowContext>.<xref:Microsoft.Xrm.Sdk.Workflow.IWorkflowContext.WorkflowMode> property to determine if the plug-in is running synchronously. |
| 417 | + |
| 418 | +## Real-time workflow stages |
| 419 | + |
| 420 | +When a workflow extension is used in a real-time (synchronous) workflow it will be invoked in the event execution pipeline stages shown in the following table. For more information : [Event execution pipeline](../event-framework.md#event-execution-pipeline) |
| 421 | + |
| 422 | +|Message |Stage | |
| 423 | +|---------|---------| |
| 424 | +|**Create**|PostOperation| |
| 425 | +|**Delete**|PreOperation| |
| 426 | +|**Update**|PreOperation or <br /> PostOperation| |
| 427 | + |
| 428 | +You can use the value in the <xref:Microsoft.Xrm.Sdk.Workflow.IWorkflowContext>.<xref:Microsoft.Xrm.Sdk.Workflow.IWorkflowContext.StageName> property to detect the stage. |
| 429 | + |
| 430 | +For the **Update** operation, the stage is configurable using **Before** or **After** options in the workflow designer. More information: [Using real-time workflows](/flow/configure-workflow-steps#using-real-time-workflows) |
| 431 | + |
| 432 | +If your workflow extension depends on data passed in the execution context, the stage it runs in will control whether data is available in the <xref:Microsoft.Xrm.Sdk.Workflow.IWorkflowContext>.<xref:Microsoft.Xrm.Sdk.IExecutionContext.InputParameters> and <xref:Microsoft.Xrm.Sdk.Workflow.IWorkflowContext>.<xref:Microsoft.Xrm.Sdk.IExecutionContext.OutputParameters>. |
| 433 | + |
| 434 | +> [!NOTE] |
| 435 | +> We don't recommend including logic dependencies based on the <xref:Microsoft.Xrm.Sdk.IExecutionContext.InputParameters> and <xref:Microsoft.Xrm.Sdk.IExecutionContext.OutputParameters>. Workflow extensions should depend on the configured [input and output parameters](#input-and-output-parameters) so that the person using the workflow extension can understand the expected behavior without having anything hidden from them. |
| 436 | + |
| 437 | +## Entity Images for workflow extensions |
| 438 | + |
| 439 | +There is no way to configure entity images for workflow extensions since you only register the assembly and the workflow activity runs in the context of the workflow. For workflow extensions entity images are available using the key values `PreBusinessEntity` and `PostBusinessEntity` respectively for the pre and post entity images. More information: [Entity Images](../understand-the-data-context.md#entity-images) |
| 440 | + |
403 | 441 |
|
404 | 442 | ### See also
|
405 | 443 |
|
|
0 commit comments