In Microsoft Dynamics 365, custom business logic plays a pivotal role in automating processes and ensuring data quality. However, there are times when you need to perform data operations without having custom business logic applied. These scenarios usually involve bulk data operations where large numbers of records are being created, updated, or deleted. As a developer of a client application, you have the flexibility to control this custom business logic.
To facilitate this, you can pass special optional parameters with your requests to control two types of custom business logic: Synchronous Logic and Power Automate Flows.
Synchronous Logic
Synchronous Logic is used when you want to enable bulk data operations to be completed as quickly as possible. You may choose to bypass synchronous logic when you're certain that the data you're changing meets the organization's requirements, or you have alternative plans to achieve this logic. By bypassing custom synchronous logic, each operation can complete faster, reducing the total time of the bulk operation.
Power Automate Flows
Power Automate Flows, on the other hand, can lead to a backlog of system jobs when used in large numbers, potentially impacting Dataverse performance. To mitigate this performance issue, you can choose not to trigger the flows while performing bulk operations.
Bypass Synchronous Logic
To bypass custom synchronous logic, you can use the "BypassCustomPluginExecution" optional parameter. This alternative avoids the need to locate and disable custom plugins containing synchronous business logic, which would disable the logic for all users while they're turned off. It also ensures that you disable the correct plugins and remember to re-enable them when you're done. Using this optional parameter, you can disable custom synchronous plugins for specific requests sent by an application configured for this option.
Two requirements must be met:
- Send the requests using the "BypassCustomPluginExecution" optional parameter.
- The user sending the requests must have the "prvBypassCustomPlugins" privilege. By default, only users with the system administrator security role have this privilege.
Please note that "prvBypassCustomPlugins" cannot be assigned through the UI, but it can be added to a security role using the API.
What Does BypassCustomPluginExecution Do?
When you send requests that bypass custom business logic, all synchronous plug-ins and real-time workflows are disabled. However, core Microsoft Dataverse system plug-ins, solution-specific plug-ins, and core behaviors for specific entities are exempted from this disabling. System plug-ins are critical for ensuring data consistency, and disabling them would result in data inconsistencies that might be challenging to rectify.
Solutions provided by Microsoft that use Dataverse, such as Microsoft Dynamics 365 Customer Service and Dynamics 365 Sales, also include essential business logic that cannot be bypassed with this option.
How to Use the BypassCustomPluginExecution Option
You can utilize the "BypassCustomPluginExecution" option with both the SDK for .NET and the Web API.
SDK for .NET:
- Set the value as an optional parameter when making requests. Here's an example of how to do it when creating a new account record:
csharpstatic void DemonstrateBypassCustomPluginExecution(IOrganizationService service)
{
Entity account = new("account");
account["name"] = "Sample Account";
CreateRequest request = new()
{
Target = account
};
request.Parameters.Add("BypassCustomPluginExecution", true);
service.Execute(request);
}
- Use the CrmServiceClient.BypassPluginExecution property:
csharpvar service = new CrmServiceClient(connectionString);
service.BypassPluginExecution = true;
var account = new Entity("account");
account["name"] = "Sample Account";
service.Create(account);
Once this setting is applied to the service, it remains set for all requests sent using the service until it's explicitly set to false.
In conclusion, controlling custom business logic execution in Dynamics 365 is essential for optimizing performance during bulk data operations. The "BypassCustomPluginExecution" option provides the flexibility to enable or disable custom plugins and flows as needed, allowing you to maintain data integrity while performing large-scale operations efficiently.
No comments:
Post a Comment