[go: up one dir, main page]

0% found this document useful (0 votes)
0 views8 pages

Dy Interview Q&A

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 8

Dynamics 365 Plugins and Custom

Workflow Activity - Interview


Questions & Answers

Ajyendra Singh
1. What is a plugin in Dynamics 365?

Answer: A plugin is custom business logic that integrates with Dynamics 365 to
modify or extend the platform's behaviour. It executes in response to specific
events, such as creating or updating records, allowing developers to implement
complex business processes.
2. How do plugins differ from workflows in Dynamics 365?
Answer: Plugins are custom code executed synchronously or asynchronously in
response to system events, providing real-time processing. Workflows, on the
other hand, are configurable processes that automate tasks based on set
conditions, typically running asynchronously and requiring no custom code.
3. Describe the event execution pipeline for plugins in Dynamics 365.
Answer: The event execution pipeline in Dynamics 365 consists of several stages:
 Pre-Validation (Stage 10): Executed before the main system operation,
outside the database transaction.
 Pre-Operation (Stage 20): Executed before the main system operation,
within the database transaction.
 Main Operation (Stage 30): The core system operation; custom plugins
cannot register here.
 Post-Operation (Stage 40): Executed after the main system operation, within
the database transaction.
Plugins can be registered in the Pre-Validation, Pre-Operation, and Post-
Operation stages.
4. What are the steps to register a plugin in Dynamics 365?
Answer: To register a plugin:
1. Develop the plugin code and compile it into a .dll file.
2. Use the Plugin Registration Tool to connect to the Dynamics 365 organization.
3. Register the new assembly and add the plugin.
4. Specify the message (e.g., Create, Update), entity, and pipeline stage for
execution.
5. Save and deploy the registered plugin.
5. Explain the concept of isolation modes in plugin execution.
Answer: Isolation modes determine the security context in which a plugin runs:
 Sandbox (Isolated): Runs in a restricted environment with limited access to
system resources, enhancing security and stability.
 None (Full Trust): Runs with full access to system resources, suitable for on-
premises deployments where the plugin requires such access.
6. How can you debug a plugin in Dynamics 365?
Answer: To debug a plugin:
1. Deploy the plugin assembly in the Debug configuration.
2. Use the Plugin Registration Tool to enable plugin profiling.
3. Perform the action in Dynamics 365 that triggers the plugin to generate a
profiling file.
4. In Visual Studio, attach the debugger to the Plugin Registration Tool process
and load the profiling file to step through the code.
7. What is a custom workflow activity in Dynamics 365?
Answer: A custom workflow activity is a custom code component that extends the
functionality of workflows in Dynamics 365. It allows developers to create reusable
logic that can be incorporated into workflows to perform complex operations not
achievable with out-of-the-box activities.
8. Describe the process of creating a custom workflow activity.
Answer: To create a custom workflow activity:
1. Develop a class library in Visual Studio that implements the CodeActivity
class.
2. Define input and output parameters using the InArgument and OutArgument
classes.
3. Implement the Execute method with the desired logic.
4. Compile the assembly and register it in Dynamics 365 using the Plugin
Registration Tool.
5. The custom activity will then be available in the workflow designer for use in
workflows.
9. How do you handle exceptions in plugins and custom workflow
activities?
Answer: Implement structured exception handling using try-catch blocks. In
plugins, throw an InvalidPluginExecutionException to display error messages to
users. For workflows, handle exceptions to ensure the workflow can manage
errors gracefully without unexpected termination.
10. What are the best practices for developing plugins and custom workflow
activities?
Answer: Best practices include:
 Keeping code efficient and performant to avoid long-running operations.
 Implementing thorough error handling and logging mechanisms.
 Ensuring plugins are stateless to maintain consistency.
 Testing plugins and workflows in a development environment before
deployment.
 Using the sandbox isolation mode unless full trust is necessary.
 Avoiding hard-coded values; instead, use configuration data where applicable.
11. What are images in the context of plugins, and why are they used?
Answer: Images are snapshots of the entity's attributes before or after the core
operation. Pre-images capture the state before the operation, and post-images
capture the state after. They are used to compare attribute values and determine
what data has changed during the operation.

12. Explain the difference between early binding and late binding in
Dynamics 365.
Answer: Early binding uses generated classes that represent the entity schema,
providing compile-time checking and IntelliSense support. Late binding uses
generic entities where attributes are accessed by names as strings, offering
flexibility but lacking compile-time validation.
13. How can you prevent infinite loops in plugins?
Answer: To prevent infinite loops, implement a mechanism to detect if the plugin
has already executed on the current context. This can be achieved by checking a
flag or context depth to ensure the plugin doesn't re-trigger itself indefinitely.
14. What is the purpose of the Plugin Registration Tool in Dynamics 365?
Answer: The Plugin Registration Tool
15. What are the key components of a plugin in Dynamics 365?
Answer: A plugin consists of a class implementing IPlugin, registered on an event,
with execution context, pipeline stage, and entity specified.
16. What are the different plugin execution modes?
Answer: Plugins execute in Synchronous (real-time) or Asynchronous
(background) mode.
17. What is a plugin assembly in Dynamics 365?
Answer: A compiled .DLL file containing one or more plugin classes registered in
Dynamics 365.
18. Can a plugin modify input parameters before execution?
Answer: Yes, in the Pre-Operation stage.
19. How do you retrieve data in a plugin?
Answer: Using IOrganizationService.Retrieve() or ITracingService.
20. What is the ExecutionContext.Depth property used for?
Answer: It helps prevent infinite loops by checking the recursion depth.
21. What is a secure configuration in a plugin?
Answer: A way to store sensitive data (like API keys) securely without hardcoding
in the plugin.
22. What is the difference between
IPluginExecutionContext.InputParameters and OutputParameters?
Answer:
 InputParameters store incoming data before execution.
 OutputParameters store results after execution.
23. What are the limitations of Sandbox mode for plugins?
Answer:
 No direct file access
 Limited external service calls
 Execution timeout restrictions

24. What is a custom workflow activity?


Answer: A class extending CodeActivity that adds reusable logic to workflows.
25. How do you pass parameters to a custom workflow activity?
Answer: Using InArgument<> (for input) and OutArgument<> (for output).
26. How can you register a custom workflow activity?
Answer: Using the Plugin Registration Tool, similar to plugins.
27. What is the difference between a custom workflow and a plugin?
Answer:
 Plugins execute on specific messages (Create, Update).
 Workflows trigger based on conditions and can be manually started.
28. What are the different types of workflows in Dynamics 365?
Answer:
 Real-time workflows (run synchronously)
 Background workflows (run asynchronously)
29. Can a custom workflow activity update records?
Answer: Yes, using IOrganizationService.Update() inside the Execute() method.
30. How do you handle exceptions in a custom workflow activity?
Answer: Use try-catch and log errors using ITracingService.Trace().
31. How do you optimize a plugin for performance?
Answer:
 Use early-bound classes for type safety.
 Minimize database calls.
 Use Shared Variables to pass data between plugins.
32. How can you share data between Pre and Post Plugins?
Answer: Using Shared Variables in PluginExecutionContext.
33. What is the recommended way to call an external API from a plugin?
Answer: Use Azure Functions or a Custom Action, since plugins have external
call restrictions.
34. When should you use a real-time workflow instead of a plugin?
Answer: When business users need configuration control.
35. What happens if a plugin throws an exception?
Answer:
 The transaction is rolled back.
 An error message is displayed to the user.
36. Where can you find logs for a failed plugin execution?
Answer: In System Jobs or Plug-in Trace Logs.
37. How do you ensure a plugin runs only for specific users?
Answer:
 Use InitiatingUserId in the execution context.
 Check the user's Security Role.

Scenario Based Questions


1. Scenario: You need to restrict certain users from updating the "Price" field in
Opportunities. How would you implement this using a plugin?
Answer:
 Register a Pre-Validation plugin on the Update message of the Opportunity
entity.
 Check the InitiatingUserId and prevent execution if unauthorized.
 Throw an InvalidPluginExecutionException if the user is restricted.

2. Scenario: You want to send an email when a new Contact is created, but only if
it has an associated Account. How would you do it?
Answer:
 Register a Post-Operation plugin on Create for the Contact entity.
 Use IOrganizationService.Retrieve() to check if the ParentCustomerId field
has an Account.
 Use SendEmailRequest to send an email.

3. Scenario: You want to automatically assign new Leads to a specific user based
on their country. How would you achieve this?
Answer:
 Register a Post-Operation plugin on Create of Lead.
 Check the Country field and assign the owner accordingly using
IOrganizationService.Update().

4. Scenario: A customer reports that a plugin is failing intermittently. How would


you debug it?
Answer:
 Enable Tracing in the Plugin Registration Tool.
 Use ITracingService.Trace() to capture logs.
 Review logs in System Jobs or Plug-in Trace Logs

5. Scenario: You need to automatically deactivate Leads that haven't been


contacted for 30 days. How do you do it?
Answer:

1. Create a Time-based background workflow that runs every 30 days.


2. Use a Custom Workflow Activity to check last contacted date.
3. Update the Lead status accordingly.
6. Scenario: A client wants an approval process where an Opportunity moves
to "Approved" only if three managers approve it. How would you implement
it?
Answer:
1. Create a workflow triggered on "Approval" entity creation.
2. Check if there are three approvals using a Custom Workflow
Activity.
3. Update Opportunity status when criteria are met.
7. Scenario: A customer needs a workflow to notify the account manager when
a high-priority case is created. How would you design this?
Answer:
1. Create a Real-time Workflow triggered on Case creation.
2. Use Custom Workflow Activity to fetch the Account Manager.
3. Send an email notification.
8. Scenario: You need to automatically deactivate Leads that haven't been
contacted for 30 days. How do you do it?
Answer:
1. Create a Time-based background workflow that runs every 30 days.
2. Use a Custom Workflow Activity to check last contacted date.
3. Update the Lead status accordingly.
9. Scenario: A client wants an approval process where an Opportunity moves
to "Approved" only if three managers approve it. How would you implement
it?
Answer:
1. Create a workflow triggered on "Approval" entity creation.
2. Check if there are three approvals using a Custom Workflow
Activity.
3. Update Opportunity status when criteria are met.
10. Scenario: A customer needs a workflow to notify the account manager when
a high-priority case is created. How would you design this?
Answer:
1. Create a Real-time Workflow triggered on Case creation.
2. Use Custom Workflow Activity to fetch the Account Manager.
3. Send an email notification.
11. Scenario: A company wants to automatically set the "Owner" field on an
Account to the creator's manager. How do you achieve this?
Answer:

 Register a Post-Operation plugin on Create for the Account.


 Use Retrieve() to get the creator’s manager.
 Update the Owner field accordingly.

12. Scenario: A client wants to log every modification to the "Credit Limit" field
of an Account. How do you design this?
Answer:

 Register a Pre-Operation plugin on Update.


 Store the old and new values in a custom log entity.

You might also like