One crucial area of focus is the design and construction of code components in Microsoft Dataverse. This involves building plug-ins as well as crafting custom APIs. A clear understanding and in-depth knowledge of these aspects are essential for an efficient Power Platform Developer. This article aims to provide an extensive review of both themes, with an added focus on examples for a more practical understanding.

Table of Contents

I: Understanding & Designing Dataverse Code Components

Microsoft Dataverse is an intricate part of the Microsoft Power platform that serves as a secure and scalable data platform built into Power Apps. It enables developers to store and manage data used by business applications.

Code components are parts of a larger application that have been specifically made to perform a particular function. In the context of the Dataverse, these could be custom entities, plug-ins, and custom APIs, to name a few.

When designing code components, it’s essential to consider:

  • Resource Optimization: Code components should not consume unnecessary resources, and should be performance-effective.
  • Scalability: Code components should be designed in a way that they can be easily scaled up or down based on future requirements.
  • Security: Code components should be secure since they might be manipulating sensitive data.

II: Microsoft Dataverse Plug-Ins

Plug-ins are custom business logic components that you can integrate with Microsoft Dataverse to modify or augment the standard behaviour of the platform.

Plug-in classes implement the IPlugin interface provided by Microsoft. They must contain an Execute method which the platform calls at runtime.

Here is a basic example of a plug-in that creates a task after creating an account:

public class AccountCreate: IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{

//Extract the tracing service for use in debugging sandboxed plug-ins.
ITracingService tracingService =
(ITracingService)serviceProvider.GetService(typeof(ITracingService));

// Obtain the execution context from the service provider.
IPluginExecutionContext context =
(IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];
try
{
// Create a task entity
Entity task = new Entity("task");
task["subject"] = "Follow up";
task["description"] =
"Follow up with the account that was just created.";
service.Create(task);
}

catch (FaultException ex)
{
throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
}

catch (Exception ex)
{
tracingService.Trace("AccountCreate: {0}", ex.ToString());
throw;
}
}
}
}

III: Custom APIs in Dataverse

Microsoft Dataverse also offers developers the ability to create custom APIs. These are HTTP endpoints that developers can define within applications for their specific needs.

Creating a custom API offers numerous advantages. You can encapsulate complex operations, apply business rules, and manage user access control, among others, which can improve the performance and usability of your applications.

To define a custom API, you must create a new Custom API record and then define its parameters and response properties.

Let’s consider an example where a Custom API named “GetTopCustomers” is designed to return the top five customers. Here, the API is defined in terms of input parameters (like year, region), output response properties (like customer name, total sales), user access control, and the functionality itself.

Ultimately, the design of Dataverse code components, including plug-ins and custom APIs, requires thorough examination of business requirements, an understanding of the underlying Microsoft Power Platform, and a knowledgeable approach to design, security and scalability. Only with this solid foundation can developers pass the PL-400 examination and succeed in the real world.

Practice Test

True or False: In Design Dataverse, plug-ins run in the background without requiring user interaction.

  • True
  • False

Answer: True

Explanation: Plug-ins are pieces of code that interact with events within Dataverse and execute in response to those events. They work in the background without requiring user interaction.

Plug-ins in Design Dataverse can be used to customize the behavior of entities.

  • True
  • False

Answer: True

Explanation: Plug-ins can be developed to modify the behavior of entities and can be triggered by events like create, update, delete, retrieve, etc.

What is the primary use of Custom APIs in Design Dataverse?

  • A. To provide custom business functionality
  • B. To run plug-ins

Answer: A. To provide custom business functionality

Explanation: Custom APIs are used to create a custom web API endpoint and define your business functionality.

True or False: Plug-ins in Design Dataverse cannot be registered to fire based on a specific event.

  • True
  • False

Answer: False

Explanation: Plug-ins in Design Dataverse can be associated with a specific event (like create, update, delete, etc.) and fire when these events occur.

True or False: One advantage of Custom APIs over actions is that they support entity-specific behavior.

  • True
  • False

Answer: True

Explanation: Custom APIs can be associated with a table, making them useful for entity-specific behavior, which is an advantage over actions.

Can you use a plug-in to prevent certain system events in Design Dataverse?

  • Yes
  • No

Answer: Yes

Explanation: Plug-in can be used to tackle system events, for example, you can use a plug-in to prevent a record from being deleted.

Can a custom API in Dataverse be used to create a custom web API endpoint?

  • Yes
  • No

Answer: Yes

Explanation: Custom APIs enables you to create a custom web API endpoint and define your own business actions or functions.

Which of the below are executed in database transaction when synchronously registered?

  • A. Custom APIs
  • B. Plug-ins
  • C. Workflows

Answer: B. Plug-ins

Explanation: When plug-ins are synchronously registered, they are executed in database transaction, which means if a plug-in fails its intended operation also rolls back.

Can the execution of a plug-in be tested in the Power Apps Maker Portal?

  • Yes
  • No

Answer: No

Explanation: While you can register and monitor a plug-in from the Power Apps Maker Portal, you cannot test its execution. For testing, you will need to use a dedicated testing tool or environment.

Do custom API requests count towards API request limits in Microsoft Dataverse?

  • Yes
  • No

Answer: Yes

Explanation: Every custom API request counts towards the total number of API requests, as defined by the license in use.

True or False: Plug-ins cannot be used to change the behavior of system events in Design Dataverse.

  • True
  • False

Answer: False

Explanation: Plug-ins are designed to customize or extend the behavior of entities in Design Dataverse, including system events.

Custom APIs in Design Dataverse are useful for defining ___________.

  • A. Custom Web API endpoints
  • B. Plug-in behavior
  • C. Database schema modifications

Answer: A. Custom Web API endpoints

Explanation: Custom APIs in Design Dataverse are used to create custom web API endpoints that can define custom business functionalities.

True or False: It is mandatory to use .NET Framework for writing plug-ins in Design Dataverse.

  • True
  • False

Answer: True

Explanation: Design Dataverse plug-ins are written using C# or VB.NET, making it necessary to use the .NET Framework.

True or False: Plug-ins can be developed and coded outside of the Design Dataverse environment.

  • True
  • False

Answer: True

Explanation: Plug-ins are developed and coded outside of the Dataverse environment, typically in Visual Studio, before being uploaded to the Dataverse.

Custom APIs in Design Dataverse can be used to create ________.

  • A. New entities
  • B. New system events
  • C. Custom web API endpoints

Answer: C. Custom web API endpoints

Explanation: Custom APIs are specifically used to create and define custom web API endpoints for specific business functionalities.

Interview Questions

What is a Custom API in the context of Microsoft Power Platform?

A Custom API is a new code-first development feature that allows developers to create web APIs in Common Data Service (nka Dataverse). These APIs allow you to create, update, and delete data within Dataverse.

What is the purpose of a plugin in Microsoft Power Platform?

A plugin is a custom business logic that integrates with Microsoft Power Platform to augment or modify the standard behavior of the platform. You can use plugins to handle events such as creating, updating, or deleting a record.

How is the execution pipeline related to Power Platform plugins?

The execution pipeline is the framework through which the event framework (plugin) passes to support the integration of custom and system (Dataverse) business logic. The execution pipeline provides a single infrastructure for the processing of a variety of system events.

What is a Pre-Operation plugin on Microsoft Power Platform?

A Pre-Operation plugin is triggered just before the main system operation takes place. Its main purpose is to modify the input parameters before they are processed by the system operation. They can cancel the operation by throwing an exception.

What is a Post-Operation plugin on Microsoft Power Platform?

A Post-Operation plugin is triggered just after the main system operation has completed. These plugins can be used when you want to access the output parameters such as the generated Id of a created record.

What are the different stages of plugin execution in Microsoft Power Platform?

There are three stages of plugin execution: Pre-event, Post-event and Main Operation. Pre-event plugins execute before the main operation, Main Operation is where the core operation like Create, Update, Delete happens and Post-event plugins execute after the main operation has completed.

Is it possible to debug a Plug-in in the Microsoft Power Platform?

Yes, using the Plug-in Profiler in the Power Platform, you can debug a plug-in. This can be achieved by attaching processes to your development environment and setting breakpoints for your plugins.

What are the four ways to authenticate your custom API in the Microsoft Power Platform’s Dataverse?

The four ways you can authenticate your custom API in the Power platform’s Dataverse are Anonymous, Basic, OAuth, and Web API Key.

What is implied by asynchronous plugin in Microsoft Power Platform?

Asynchronous plugins are plugins that execute in the background, making them suitable for long-running operations that do not need to delay the main system operation.

What functionality does the ‘RevokeConsent’ action in Custom APIs provide?

The ‘RevokeConsent’ action in Custom APIs allows a user to revoke their consent to a particular agreement. This means the user will no longer be bound by the terms of that agreement.

Leave a Reply

Your email address will not be published. Required fields are marked *